Exemplo n.º 1
0
        public ActionResult BannerAdd(BannerModel model, HttpPostedFileBase Photo)
        {
            if (Photo != null)
            {
                var fileName = Path.GetFileNameWithoutExtension(Photo.FileName);
                var extension = Path.GetExtension(Photo.FileName);
                var fileFullName = Guid.NewGuid() + fileName.Replace(" ", "").Replace(".", "") + extension;
                var path = Path.Combine(Server.MapPath("~/Content/images/manset"), fileFullName);
                Photo.SaveAs(path);

                Banner banner = new Banner
                {
                    TitleMain = model.TitleMain,
                    TitleSub = model.TitleSub,
                    Photo = "images/manset/" + fileFullName,
                    Url = model.Url,
                    UrlTarget = model.UrlTarget,
                    Order = model.Order,
                    Active = model.Active
                };

                _bannerService.Insert(banner);
                _uow.SaveChanges();
            }

            return RedirectToAction("ListBanner");
        }
Exemplo n.º 2
0
 // GET: Admin/Banner
 public ActionResult ListBanner()
 {
     BannerModel _bannerModel = new BannerModel();
     _bannerModel.BannerList = _bannerService.GetAll().ToList();
     
     return View(_bannerModel);
 }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            Banner banner = _bannerService.Find(id);

            BannerModel _bannerModel = new BannerModel
            {
                Id = banner.Id,
                TitleMain = banner.TitleMain,
                TitleSub = banner.TitleSub,
                Active = banner.Active,
                Order = banner.Order,
                Url = banner.Url,
                UrlTarget = banner.UrlTarget
            };

            return View(_bannerModel);
        }
Exemplo n.º 4
0
        public ActionResult BannerEdit(BannerModel model, HttpPostedFileBase Photo)
        {
            int id = int.Parse(Request.Form["hfId"]);
            Banner banner = _bannerService.Find(id);

            if (Photo != null)
            {
                var fileName = Path.GetFileNameWithoutExtension(Photo.FileName);
                var extension = Path.GetExtension(Photo.FileName);
                var fileFullName = Guid.NewGuid() + fileName.Replace(" ", "").Replace(".", "") + extension;
                var path = Path.Combine(Server.MapPath("~/Content/images/manset"), fileFullName);
                Photo.SaveAs(path);
                banner.Photo = "images/manset/" + fileFullName;
            }

            banner.TitleMain = model.TitleMain;
            banner.TitleSub = model.TitleSub;
            banner.Url = model.Url;
            banner.UrlTarget = model.UrlTarget;
            banner.Active = model.Active;
            banner.Order = model.Order;

            _bannerService.Update(banner);
            _uow.SaveChanges();

            return RedirectToAction("ListBanner");
        }