コード例 #1
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                if (!order.IsMultyProduct && order.ProductId == null)
                {
                    ModelState.AddModelError("productRequired", "محصول را انتخاب کنید.");

                    ViewBag.CustomerId = new SelectList(UnitOfWork.CustomerRepository.Get(), "Id", "FullName", order.CustomerId);
                    ViewBag.ProductId  = new SelectList(UnitOfWork.ProductRepository.Get(), "Id", "Title", order.ProductId);

                    return(View(order));
                }


                order.IsActive = true;
                order.Code     = GenerateCode.GetOrderCode();
                order.ParentId = null;
                order.IsLatest = true;

                UnitOfWork.OrderRepository.Insert(order);
                UnitOfWork.Save();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(UnitOfWork.CustomerRepository.Get(), "Id", "FullName", order.CustomerId);
            ViewBag.ProductId  = new SelectList(UnitOfWork.ProductRepository.Get(), "Id", "Title", order.ProductId);

            return(View(order));
        }
コード例 #2
0
        public Guid SetOrder(Guid orderId, Guid customerId, Guid productId)
        {
            Guid newOrderId = new Guid(System.Web.Configuration.WebConfigurationManager.AppSettings["newOrderId"]);

            if (orderId == newOrderId)
            {
                Order order = new Order()
                {
                    Id             = Guid.NewGuid(),
                    CustomerId     = customerId,
                    IsMultyProduct = false,
                    CreationDate   = DateTime.Now,
                    Code           = GenerateCode.GetOrderCode(),
                    ProductId      = productId,
                    IsActive       = true,
                    IsDeleted      = false,
                    ParentId       = null,
                };

                UnitOfWork.OrderRepository.Insert(order);

                return(order.Id);
            }

            return(orderId);
        }
コード例 #3
0
        public Guid CreateParentOrder(Guid customerId)
        {
            Order order = new Order()
            {
                Code       = GenerateCode.GetOrderCode(),
                ParentId   = null,
                CustomerId = customerId,
                IsActive   = true,
                IsLatest   = true
            };

            UnitOfWork.OrderRepository.Insert(order);
            return(order.Id);
        }