コード例 #1
0
        public ActionResult Edit(MainPageBanner model)
        {
            _repository.LangId = CurrentLangId;
            var banner = _repository.GetMainPageBanner(model.Id);

            var file = Request.Files[0];
            if (file != null && !string.IsNullOrEmpty(file.FileName))
            {
                if (!string.IsNullOrEmpty(banner.ImageSource))
                {
                    ImageHelper.DeleteImage(banner.ImageSource);
                }

                string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                string filePath = Server.MapPath("~/Content/Images");

                filePath = Path.Combine(filePath, fileName);
                //GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500);
                file.SaveAs(filePath);
                banner.ImageSource = fileName;
            }

            banner.Url = model.Url;
            _repository.SaveMainPageBanner(banner);


            return RedirectToAction("Index");
        }
コード例 #2
0
        public ActionResult Create(MainPageBanner model)
        {
            _repository.LangId = CurrentLangId;
            try
            {
                

                var file = Request.Files[0];

                if (file != null && !string.IsNullOrEmpty(file.FileName))
                {
                    
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    //GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500);
                    file.SaveAs(filePath);
                    
                    var mainPageBanner = new MainPageBanner {IsSiteBanner = true, ImageSource = fileName, Url = model.Url};
                    _repository.AddMainPageBanner(mainPageBanner);
                }


            }
            catch (Exception ex)
            {
                TempData["errorMessage"] = ex.Message;
                return View();
            }
            return RedirectToAction("Index");
        }
コード例 #3
0
ファイル: MainPageBanner.cs プロジェクト: fathurxzz/aleqx
 public void SaveMainPageBanner(MainPageBanner mainPageBanner)
 {
     _store.SaveChanges();
 }
コード例 #4
0
ファイル: MainPageBanner.cs プロジェクト: fathurxzz/aleqx
 public int AddMainPageBanner(MainPageBanner mainPageBanner)
 {
     _store.MainPageBanners.Add(mainPageBanner);
     _store.SaveChanges();
     return mainPageBanner.Id;
 }