示例#1
0
        public ActionResult Edit(int id)
        {
            var app          = new ServiceReference.ContractClient();
            var BannerClient = app.GetBannerById(id);

            var model = new BannerViewModel
            {
                Id          = BannerClient.Id,
                ImageUrl    = BannerClient.ImageUrl,
                Description = BannerClient.Description,
                Title       = BannerClient.Title,
                Url         = BannerClient.Url,
            };

            return(View(model));
        }
示例#2
0
        public ActionResult Edit(BannerViewModel banner)
        {
            var app  = new ServiceReference.ContractClient();
            var path = string.Empty;

            if (Request.Files.Count == 1)
            {
                var bannerClient = app.GetBannerById(banner.Id);
                ImageHelper.DeleteImage(bannerClient.ImageUrl);
                path = ImageHelper.SaveImage("Banner", Request.Files[0], Server.MapPath("~/Image"));
            }
            var model = new ServiceReference.Banner
            {
                Id          = banner.Id,
                ImageUrl    = path,
                Description = banner.Description,
                Title       = banner.Title,
                Url         = banner.Url,
            };

            app.UpdateBanner(model);

            return(RedirectToAction("GetAll"));
        }