Пример #1
0
        public ActionResult Edit(BannerViewModel model, HttpPostedFileBase uploadFile)
        {
            if (ModelState.IsValid)
            {
                if (uploadFile != null && uploadFile.ContentLength > 0)
                {
                    ImageUpload imageUpload = new ImageUpload {
                        IsScale = false, SavePath = ImageUpload.LoadPathBanners
                    };
                    ImageResult imageResult = imageUpload.RenameUploadFile(uploadFile);

                    if (imageResult.Success)
                    {
                        // Add new image to database
                        var photo = new share_Images
                        {
                            ImageName = imageResult.ImageName,
                            ImagePath = imageResult.ImagePath
                        };
                        //var imageId = _productService.AddImage(photo);
                        //if (imageId != null)
                        //{
                        //    // Add banner
                        //    model.ImageId = imageId.Value;
                        //}
                    }
                    else
                    {
                        ViewBag.Error = imageResult.ErrorMessage;
                    }
                }

                _bannerService.EditBanner(model);
                return(RedirectToAction("Index"));
            }

            PopulateBannerTypesDropDownList((Portal.Infractructure.Utility.Define.BannerTypes)model.Type);
            PopulateStatusDropDownList((Portal.Infractructure.Utility.Define.Status)model.Status);
            return(View(model));
        }