-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerController.cs
More file actions
175 lines (137 loc) · 4.64 KB
/
Copy pathCustomerController.cs
File metadata and controls
175 lines (137 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
namespace MBDEVproAPI.API.Controllers
{
//[ApiController]
//[Route("[controller]")]
public class CustomerController : BaseController
{
#region variables and constructors
private ICustomerService _customerService;
public CustomerController(ICustomerService customerService)
{
_customerService = customerService;
}
#endregion
#region GET: all customers
/// <summary>
/// GET: returns all Citation Types for a Project
/// "CustomerControllerGetAllCustomers": "Customer/GetAllCustomers",
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult<CustomerModel> GetAllCustomers(int BusinessID)
{
try
{
var customers = _customerService.GetAllCustomers(BusinessID);
// can check null here.
return Ok(customers);
}
catch (Exception ex)
{
return BadRequest("Customer API error: " + ex.Message + " | " + ex.InnerException);
}
}
// GET: api/GetAllGetAllCustomers
//[HttpGet]
//public async Task<ActionResult<IEnumerable<Customer>>> GetAllGetAllCustomers()
//{
// var customers = await _customerService.GetAllCustomers();
// if (customers == null)
// {
// return NotFound();
// }
// return customers;
//}
////EXAMPLE
//#region Get All Customers
//[HttpGet("{id}")]
//public IEnumerable<CustomerModel> GetAllCustomers()
//{
// return (IEnumerable<CustomerModel>)Ok(_customerService.GetAllCustomers());
//}
//#endregion
#endregion
//// GET: api/Customer/5
//[HttpGet("{id}")]
//public async Task<ActionResult<CustomerModel>> GetCustomer(int id)
//{
// var customer = await _context.Customers.FindAsync(id);
// if (customer == null)
// {
// return NotFound();
// }
// return customer;
//}
//// GET: api/Customer
//[HttpGet]
//public async Task<ActionResult<IEnumerable<Customer>>> GetCustomers()
//{
// return await _context.Customers.ToListAsync();
//}
//// GET: api/Customer/5
//[HttpGet("{id}")]
//public async Task<ActionResult<Customer>> GetCustomer(int id)
//{
// var customer = await _context.Customers.FindAsync(id);
// if (customer == null)
// {
// return NotFound();
// }
// return customer;
//}
//// PUT: api/Customer/5
//// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
//[HttpPut("{id}")]
//public async Task<IActionResult> PutCustomer(int id, Customer customer)
//{
// if (id != customer.CustomerID)
// {
// return BadRequest();
// }
// _context.Entry(customer).State = EntityState.Modified;
// try
// {
// await _context.SaveChangesAsync();
// }
// catch (DbUpdateConcurrencyException)
// {
// if (!CustomerExists(id))
// {
// return NotFound();
// }
// else
// {
// throw;
// }
// }
// return NoContent();
//}
//// POST: api/Customer
//// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
//[HttpPost]
//public async Task<ActionResult<Customer>> PostCustomer(Customer customer)
//{
// _context.Customers.Add(customer);
// await _context.SaveChangesAsync();
// return CreatedAtAction("GetCustomer", new { id = customer.CustomerID }, customer);
//}
//// DELETE: api/Customer/5
//[HttpDelete("{id}")]
//public async Task<IActionResult> DeleteCustomer(int id)
//{
// var customer = await _context.Customers.FindAsync(id);
// if (customer == null)
// {
// return NotFound();
// }
// _context.Customers.Remove(customer);
// await _context.SaveChangesAsync();
// return NoContent();
//}
//private bool CustomerExists(int id)
//{
// return _context.Customers.Any(e => e.CustomerID == id);
//}
}
}