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)); }
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); }
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); }