public void DeleteBanner(Banner Banner) { string FileName = Banner.Image; if (FileName != "default.ico") { System.IO.File.Delete(HttpContext.Current.Server.MapPath("~/Images/Banner/Large/" + FileName)); System.IO.File.Delete(HttpContext.Current.Server.MapPath("~/Images/Banner/Small/" + FileName)); } _RBanner.DeleteBanner(Banner); }
public void SaveBanner(Banner Banner) { if (Banner.Id == 0) { _RBanner.Add(Banner); } else { _uow.Entry(Banner).State = EntityState.Modified; } _uow.SaveChanges(); }
/// <summary> /// gets the detail of a banner /// </summary> /// <param name="id">identifier of banner</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int?id) { BannerRepository objbanner = new BannerRepository(SessionCustom); SectionManagement objsection = new SectionManagement(SessionCustom, HttpContext); SectionRepository sectionrepository = new SectionRepository(SessionCustom); PositionRepository objposition = new PositionRepository(SessionCustom); Domain.Entities.Banner banner = null; bool?isHome = null; if (id != null) { objbanner.Entity.BannerId = id; objbanner.Load(); banner = objbanner.Entity; ViewBag.id = id; BannersectionRepository objbannersection = new BannersectionRepository(SessionCustom); objbannersection.Entity.BannerId = id; List <Bannersection> collsections = objbannersection.GetAll(); objsection.CreateTreeViewCheck(sectionrepository.GetAll().FindAll(t => t.LanguageId == CurrentLanguage.LanguageId), collsections); isHome = collsections.Exists(t => t.SectionId == 0); } else { objsection.CreateTreeViewCheck(sectionrepository.GetAll().FindAll(t => t.LanguageId == CurrentLanguage.LanguageId), null); } return(this.View(new Banners() { UserPrincipal = CustomUser, Banner = banner, ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext), Module = this.Module, TreeView = objsection.Tree, Collposition = objposition.GetAll(), IsHome = isHome, CurrentLanguage = CurrentLanguage })); }
public void DeleteBanner(Banner Banner) { _RBanner.Remove(Banner); _uow.SaveChanges(); }
public ActionResult CreateBanner(validationImage validationBanner, string alt) { if (IsValidSessions()) { string filename = SaveSitePartImage(validationBanner.ImageBanner); if (filename != "") { TempData["result"] = "OK"; Banner Banner = new Banner() { LanguageId = Convert.ToInt32(Session["Language"].ToString()), CreationDate = DateTime.Now.Date, Image = filename, alt = alt }; _RBanner.SaveBanner(Banner); TempData["Message"] = "عملیات با موفقیت انجام شد."; ViewData.ModelState.Clear(); } else { TempData["result"] = "Error"; TempData["Message"] = "فایل ارسالی مجاز نمی باشد"; return View("CreateBanner"); } return RedirectToAction("BannerList"); } else return RedirectToAction("Login", "Home"); }