public ActionResult CreateProduct(int orderId) { var rep = new OrdersRepository(); var products = rep.GetAllProducts(); ViewBag.Products = products; var viewDetail = new Models.CreatingDetailViewModel { OrderID = orderId }; return(PartialView("_Product", viewDetail)); }
public ActionResult CreateProduct(Models.CreatingDetailViewModel detail) { if (ModelState.IsValid) { var rep = new OrdersRepository(); Mapper.Initialize(cfg => cfg.CreateMap <Models.CreatingDetailViewModel, DataAccessLayer.Models.CreatingOrderDetail>() .ForMember("Discount", opt => opt.MapFrom(src => (decimal)src.Discount / 100))); var creatingDetail = Mapper.Map <Models.CreatingDetailViewModel, DataAccessLayer.Models.CreatingOrderDetail>(detail); rep.AddOrderDetail(creatingDetail); return(RedirectToAction("Details", "Home", new { orderId = detail.OrderID })); } return(RedirectToAction("ErrorMessage", "Home", new { message = Resources.ProductAddError })); }