Пример #1
0
        public void Insert(string username)
        {
            using (var rep = new OrderRepository())
            {
                ApplicationDbContext dbcon = new ApplicationDbContext();

                OrderView model = new OrderView();
                var obj = new PatientBusiness();
                var shop = new ShoppingCartBusiness();

                var person = dbcon.Patients.SingleOrDefault(x => x.UserName.Equals(username));

                var tot = shop.ComputeTotal(username);

                if (tot != 0)
                {

                    if (person != null)
                    {
                        model.FirstName = person.FirstName;
                        model.LastName = person.LastName;

                    }
                    model.TotalCost = shop.ComputeTotal(username);
                    model.Username = username;

                    rep.Insert(ConvertToProduct(model));
                }
                ShoppingCartBusiness biz = new ShoppingCartBusiness();
                biz.UpdateCheck(username);
            }
        }
Пример #2
0
        public void Update(OrderView modelView)
        {
            using (var rep = new OrderRepository())
            {
                var dev = rep.GetById(modelView.OrderId);

                if (dev != null)
                {

                    rep.Update(dev);
                }
            }
        }
Пример #3
0
        private static Order ConvertToProduct(OrderView modelView)
        {
            var x = new Order
            {

                FirstName = modelView.FirstName,
                LastName = modelView.LastName,
                OrderId = modelView.OrderId,
                TotalCost = modelView.TotalCost,
                Username = modelView.Username

            };
            return x;
        }