Esempio n. 1
0
        public ActionResult Publish(int id)
        {
            DraftProduct d = this.publishingService.GetAllDrafts().Where(dr => dr.ID == id).FirstOrDefault();

            this.publishingService.Publish(d, d.Publish, d.OriginalProduct);
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public DraftProduct PopularDraftReviewFromModel(DraftProduct draft, ProductCategory category, Supplier supplier, Product origin)
 {
     draft.OriginalProduct  = origin;
     draft.Category         = category;
     draft.Supplier         = supplier;
     draft.Name             = this.Name;
     draft.Price            = this.Price;
     draft.ShortDescription = this.ShortDescription;
     draft.urlImage         = this.urlImage;
     draft.FullDescription  = this.FullDescription;
     return(draft);
 }
Esempio n. 3
0
 public ProductModel(DraftProduct Draft, bool isDraft)
 {
     this.ID               = Draft.ID;
     this.Name             = Draft.Name;
     this.CategoryId       = Draft.Category.ID;
     this.Price            = Draft.Price;
     this.CategoryName     = Draft.Category.Name;
     this.StatusId         = Draft.PublicationStatus.ID;
     this.StatusName       = Draft.PublicationStatus.Name;
     this.supplierId       = Draft.Supplier.ID;
     this.supplierName     = Draft.Supplier.Name;
     this.urlImage         = string.Concat(urlFolderImage, Draft.urlImage);
     this.ShortDescription = Draft.ShortDescription;
     this.FullDescription  = Draft.FullDescription;
     this.IsDraft          = isDraft;
 }
Esempio n. 4
0
 public ProductModel(DraftProduct draft)
 {
     ID               = draft.ID;
     CategoryId       = draft.Category.ID;
     CategoryName     = draft.Category.Name;
     FullDescription  = draft.FullDescription;
     supplierName     = draft.Supplier.Name;
     supplierId       = draft.Supplier.ID;
     Name             = draft.Name;
     Price            = draft.Price;
     ShortDescription = draft.ShortDescription;
     StatusId         = draft.PublicationStatus.ID;
     StatusName       = draft.PublicationStatus.Name;
     urlImage         = string.Concat(urlFolderImage, draft.urlImage);
     IsDraft          = true;
     IdOriginal       = draft.OriginalProduct != null ? draft.OriginalProduct.ID : 0;
 }
Esempio n. 5
0
        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"));
        }