public ActionResult Edit(int id, bool isDraft) { if (!isDraft) { ProductModel model = new ProductModel(this.publishingService.GetByID(id)); SetarViewBags(); return View(model); } else { ProductModel model = new ProductModel(this.publishingService.GetDraftById(id), isDraft); SetarViewBags(); return View(model); } }
public ActionResult Create(ProductModel model, HttpPostedFileBase FileImage) { if (!model.isValid(FileImage)) { ModelState.AddModelError("urlImage", model.RequiredImageMessage); } if (ModelState.IsValid) { this.helperService.SaveFile(FileImage, model.urlFolderImage); model.urlImage = FileImage.FileName; this.publishingService.CreateDraft(model.CreateDraftReviewFromModel(this.productCategoryService.GetByID(model.CategoryId), this.supplierService.GetByID(model.supplierId), null),null); return RedirectToAction("Index"); } SetarViewBags(); return View(); }
public ActionResult Edit(ProductModel model, HttpPostedFileBase ImageFile) { if (ModelState.IsValid) { ProductCategory category = this.productCategoryService.GetByID(model.CategoryId); Supplier supplier = this.supplierService.GetByID(model.supplierId); var produto = this.publishingService.GetByID(model.ID); if (!model.IsDraft) { if (ImageFile == null && produto != null) model.urlImage = produto.urlImage; else model.urlImage = ImageFile.FileName; DraftProduct d = model.CreateDraftReviewFromModel(category, supplier, produto); this.publishingService.CreateDraft(d, produto); } else { if (ImageFile == null && produto != null) model.urlImage = produto.urlImage; else model.urlImage = ImageFile.FileName; var draft = this.publishingService.GetDraftById(model.ID); this.publishingService.UpdateDraft(model.PopularDraftReviewFromModel(draft, category, supplier, draft.OriginalProduct)); ; } } SetarViewBags(); return RedirectToAction("Index"); }