public async Task <IActionResult> PutOrder(int id, Order order) { if (id != order.Id) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task AddToken(TokenDetailDto dto) { var token = new Token() { OrderId = dto.OrderID, Status = dto.Status, Description = dto.Description, PayMethod = dto.PayMethod, Urgent = dto.Urgent }; _context.Tokens.Add(token); await _context.SaveChangesAsync(); }
public async Task AddOrder(OrderDto order) { var newOrder = new Order() { Total = order.Total, CustomerId = order.CustomerId }; var orderItems = new List <OrderItem>(); foreach (var product in order.Products) { var orderItem = new OrderItem() { ProductId = product.ProductId, Quantity = product.Quantity, Total = product.Total }; orderItems.Add(orderItem); } newOrder.OrderItems = orderItems; _context.Orders.Add(newOrder); await _context.SaveChangesAsync(); }
public async Task AddCustomer(CustomerDto customer) { var cust = new Customer() { Address = customer.Address, Age = customer.Age, Allergies = customer.Allergies, Email = customer.Email, FirstName = customer.FirstName, LastName = customer.LastName, password = customer.password, Telephone = customer.Telephone }; await _mailService.SendEmail("*****@*****.**", "Subject", "This is body"); _context.Customers.Add(cust); await _context.SaveChangesAsync(); }