public async Task <Product> Add(Product product) { await _context.Product.AddAsync(product); await _context.SaveChangesAsync(); return(product); }
public async Task <Customer> Add(Customer customer) { await _context.Customer.AddAsync(customer); await _context.SaveChangesAsync(); return(customer); }
public async Task <OrderItem> Add(OrderItem orderItem) { await _context.OrderItem.AddAsync(orderItem); await _context.SaveChangesAsync(); return(orderItem); }
public async Task <Order> Add(Order order) { await _context.Order.AddAsync(order); await _context.SaveChangesAsync(); return(order); }
public async Task <Salesperson> Add(Salesperson salesperson) { await _context.Salesperson.AddAsync(salesperson); await _context.SaveChangesAsync(); return(salesperson); }
public async Task <IActionResult> PostCustomer([FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Customer.Add(customer); await _context.SaveChangesAsync(); return(CreatedAtAction("getCustomer", new { id = customer.CustomerId }, customer)); }
public async Task <IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.CustomerId) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok(customer)); }
public async Task <IActionResult> DeleteCustomer(int id) { try { var customer = await _h_Plus_SportsContext.Customer.FindAsync(id); if (customer == null) { return(NotFound()); } _h_Plus_SportsContext.Customer.Remove(customer); return((await _h_Plus_SportsContext.SaveChangesAsync()) > 0 ? Ok() : StatusCode(500)); } catch (DbUpdateConcurrencyException) { throw; } catch (Exception exp) { throw; } }
public async Task <bool> AddCustomerAsync(Customer customer) { _h_Plus_SportContext.Customer.Add(customer); return(await _h_Plus_SportContext.SaveChangesAsync() > 0 ? true : false); }