Exemplo n.º 1
0
        public void CheckOut(ApplicationUser user)
        {
            IEnumerable <Order> orders    = _orderRepo.GetOrdersForUser(user.Id);
            List <Order>        newOrders = new List <Order>();

            orders.Select(order => {
                if (order.OrderLine == null)
                {
                    newOrders.Add(order);
                    _orderLineRepo.SetEntityState(order, EntityState.Unchanged);
                }

                return(order);
            });

            OrderLine line = new OrderLine()
            {
                User      = user,
                Orders    = newOrders,
                Date      = DateTime.Now,
                Delivered = false
            };

            _orderLineRepo.SetEntityState(user, EntityState.Unchanged);
            _orderLineRepo.Insert(line);
            _orderLineRepo.SaveChanges();

            //add to queue

            //string json = JsonConvert.SerializeObject(line);
        }
Exemplo n.º 2
0
        private void DoAction(Device device, IEnumerable <int> selectedFrameworks, IEnumerable <int> selectedOSs, DeviceServiceDelegate deviceAction)
        {
            device.Framework = GiveObjects <Framework>(selectedFrameworks, _frameworkRepo);
            device.OS        = GiveObjects <OS>(selectedOSs, _osRepo);

            SetStateUnchanged <Framework>(device.Framework);
            SetStateUnchanged <OS>(device.OS);

            deviceAction(device);
            _deviceRepo.SaveChanges();
        }