Пример #1
0
        private ActionResult MakeAnOrderComplete(CustomerOrderViewModel model)
        {
            try
            {
                var cmd = new MakeNewOrderCommand {
                    CustomerId = new Guid(Request.Params["CustomerId"])
                };
                foreach (var item in model.OrderItems)
                {
                    cmd.Quantities.Add(item.ProductId, item.Quantity);
                }

                using (var s = UnitOfWork)
                {
                    var ctx = new ContextHandler <Order, MakeNewOrderRole>(repo);
                    ctx.Bind(cmd)
                    .Execute();
                    s.Commit();
                }

                return(MakeAnOrder());
            }
            catch (Exception err)
            {
                throw err;
            }
        }
        public ActionResult Register(CreateNewProductCommand cmd)
        {
            try
            {
                using (var s = UnitOfWork)
                {
                    ContextHandler<Product, CreateNewProductRole> ctx = new ContextHandler<Product, CreateNewProductRole>(repo);
                    ctx.Bind(cmd)
                       .Execute();
                    s.Commit();

                    return View();
                }
            }
            catch (Exception err)
            {
                return null;
            }
        }
        public ActionResult Register(CreateNewCustomerCommand cmd)
        {
            using (var s = UnitOfWork)
            {
                try
                {
                    ContextHandler <Customer, CreateNewCustomerRole> ctx = new ContextHandler <Customer, CreateNewCustomerRole>(repo);
                    ctx.Bind(cmd)
                    .Execute();
                    s.Commit();

                    return(View());
                }
                catch (Exception err)
                {
                    throw new Exception(err.Message);
                }
            }
        }
Пример #4
0
        public ActionResult Edit(Guid id, Guid rowId, Guid customerId, Guid productId)
        {
            try
            {
                using (var s = UnitOfWork)
                {
                    var cmd = new ChangeProductQuantityInOrderItemCommand { AggregateRootId = id, RowId = rowId, CustomerId = customerId, ProductId = productId, Quantity = 5 };
                    var ctx = new ContextHandler<Order, ChangeProductQuantityInOrderItemRole>(repo);
                    ctx.Bind(cmd)
                       .Execute();
                    s.Commit();
                }

            }
            catch (Exception err)
            {
            }
            return null;
        }
        public ActionResult Register(CreateNewProductCommand cmd)
        {
            try
            {
                using (var s = UnitOfWork)
                {
                    ContextHandler <Product, CreateNewProductRole> ctx = new ContextHandler <Product, CreateNewProductRole>(repo);
                    ctx.Bind(cmd)
                    .Execute();
                    s.Commit();

                    return(View());
                }
            }
            catch (Exception err)
            {
                return(null);
            }
        }
Пример #6
0
 public ActionResult Edit(Guid id, Guid rowId, Guid customerId, Guid productId)
 {
     try
     {
         using (var s = UnitOfWork)
         {
             var cmd = new ChangeProductQuantityInOrderItemCommand {
                 AggregateRootId = id, RowId = rowId, CustomerId = customerId, ProductId = productId, Quantity = 5
             };
             var ctx = new ContextHandler <Order, ChangeProductQuantityInOrderItemRole>(repo);
             ctx.Bind(cmd)
             .Execute();
             s.Commit();
         }
     }
     catch (Exception err)
     {
     }
     return(null);
 }
        public ActionResult Register(CreateNewCustomerCommand cmd)
        {
            using (var s = UnitOfWork)
            {
                try
                {
                    ContextHandler<Customer, CreateNewCustomerRole> ctx = new ContextHandler<Customer, CreateNewCustomerRole>(repo);
                    ctx.Bind(cmd)
                       .Execute();
                    s.Commit();

                    return View();

                }
                catch(Exception err)
                {
                    throw new Exception(err.Message);
                }
            }
        }
Пример #8
0
        private ActionResult MakeAnOrderComplete(CustomerOrderViewModel model)
        {
            try
            {
                var cmd = new MakeNewOrderCommand { CustomerId = new Guid(Request.Params["CustomerId"]) };
                foreach (var item in model.OrderItems)
                {
                    cmd.Quantities.Add(item.ProductId, item.Quantity);
                }

                using (var s = UnitOfWork)
                {
                    var ctx = new ContextHandler<Order, MakeNewOrderRole>(repo);
                    ctx.Bind(cmd)
                       .Execute();
                    s.Commit();
                }

                return MakeAnOrder();
            }
            catch(Exception err)
            {
                throw err;
            }
        }