示例#1
0
        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());
        }
示例#2
0
        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();
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }