Example #1
0
        public IHttpActionResult CreateOrder(int id, CreateOrderDto createOrderDto)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            repo.CreateOrder(id, createOrderDto);

            return Ok();
        }
Example #2
0
        public void CreateOrder(int id, CreateOrderDto createOrderDto)
        {
            Order order = new Order
            {
                FirstName = createOrderDto.FirstName,
                LastName = createOrderDto.LastName,
                Address = createOrderDto.Address,
                City = createOrderDto.City,
                PostCode = createOrderDto.PostCode
            };

            order.CartId = id;
            order.OrderDate = DateTime.Now;
            order.Status = "W realizacji";
            var price = CartCheckout(id);
            order.Price = price.TotalCost;

            // userId = cartId
            order.UserId = id;

            // create order
            db.Orders.Add(order);
            // delete items from basket
            DeleteCartLines(id);
            SaveChanges();
        }