public ActionResult AllProductsOrder(int supplierId) { var supplier = _supplierApi.All().FirstOrDefault(x => x.SupplierId == supplierId); var viewmodel = new SupplierProductViewModel() { Supplier = supplier, Products = _productApi.GetAllForSupplier(supplier) }; return(PartialView(@"~\Views\Retailer\RetailerCommon\_AllSupplierProductsOrder.cshtml", viewmodel)); }
public ActionResult Update(SupplierProductViewModel model) { if (!this.ModelState.IsValid) { this.TempData["Categories"] = this.Cache.Get( "categories", () => this.Categories.GetAll() .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }) .ToList(), 30 * 60); return(this.View(model)); } var product = Mapper.Map <Product>(model); if (model.UploadedImage != null) { using (var memory = new MemoryStream()) { model.UploadedImage.InputStream.CopyTo(memory); var content = memory.GetBuffer(); var newImage = new Image { Content = content, FileExtension = model.UploadedImage.FileName.Split(new[] { '.' }).Last() }; product.Image = newImage; } } this.Products.Update(product); return(this.RedirectToAction("Index", "Products", new { area = "Private" })); }
public ActionResult Update(SupplierProductViewModel model) { if (!this.ModelState.IsValid) { this.TempData["Categories"] = this.Cache.Get( "categories", () => this.Categories.GetAll() .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }) .ToList(), 30 * 60); return this.View(model); } var product = Mapper.Map<Product>(model); if (model.UploadedImage != null) { using (var memory = new MemoryStream()) { model.UploadedImage.InputStream.CopyTo(memory); var content = memory.GetBuffer(); var newImage = new Image { Content = content, FileExtension = model.UploadedImage.FileName.Split(new[] { '.' }).Last() }; product.Image = newImage; } } this.Products.Update(product); return this.RedirectToAction("Index", "Products", new { area = "Private" }); }
public ActionResult Create(SupplierProductViewModel model) { if (!this.ModelState.IsValid) { this.TempData["Categories"] = this.Cache.Get( "categories", () => this.Categories.GetAll() .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }) .ToList(), 30 * 60); return(this.View(model)); } var product = Mapper.Map <Product>(model); product.SupplierId = this.UserProfile.Organization.Id; this.Products.Add(product); return(this.RedirectToAction("Index", "Products", new { area = "Private" })); }
public ActionResult Create(SupplierProductViewModel model) { if (!this.ModelState.IsValid) { this.TempData["Categories"] = this.Cache.Get( "categories", () => this.Categories.GetAll() .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }) .ToList(), 30 * 60); return this.View(model); } var product = Mapper.Map<Product>(model); product.SupplierId = this.UserProfile.Organization.Id; this.Products.Add(product); return this.RedirectToAction("Index", "Products", new { area = "Private" }); }