Esempio n. 1
0
        void IOrderHelper.AddOrder(OrderModel model)
        {
            var adress = model.Client.Name + " " + model.Client.Surname
                + ";" + model.Client.Street + ";" + model.Client.PostalCode
                + ";" + model.Client.City;

            var order = new orders
            {
                Id_Client = model.Client.Id,
                Id_Delivery = model.selectedDeliveryId,
                Id_Status = 1,
                ToPay = model.cart.ComputeTotalValue(),
                AdressToDelivery = adress,
                InsertTime = DateTime.Now,
            };

            //dodanie nowego zamówienia => przejscie do wypełnienia szczegółów zamówienia
            var orderId = _ordersRepository.AddOrder(order);

            var orderDetails = new List<order_details>();
            var arrayToList = model.cart.Lines.ToList();

            for (int i = 0; i < arrayToList.Count - 1; i++)
            {
                orderDetails.Add(new order_details
                {
                    Id_Order = orderId,
                    Id_Item = arrayToList[i].Item.Id,
                    Quantity = arrayToList[i].Quantity
                });
            }

            _ordersRepository.AddOrderDetails(orderDetails);
        }
Esempio n. 2
0
 int IOrdersRepository.GetIdOrder(orders model)
 {
     return _efDbContext.Orders
         .Where(x => x.Equals(model))
         .Select(x => x.Id)
         .FirstOrDefault();
 }
Esempio n. 3
0
        int IOrdersRepository.AddOrder(orders order)
        {
            _efDbContext.Orders.Add(order);
            _efDbContext.SaveChanges();

            var notyfications = new client_notyfications
            {
                Id_Client = order.Id_Client,
                AsRead = false,
                Message = "Złożono zamówienie o numerze " + order.Id + " w dniu " + order.InsertTime.ToShortDateString()
            };

            _efDbContext.ClientNotyfications.Add(notyfications);
            _efDbContext.SaveChanges();

            return order.Id;
        }