Ejemplo n.º 1
0
        public ActionResult Edit(SiteEditViewModel model)
        {
            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                var fileName = this.Request.Files[0].FileName;
                var extension = Path.GetExtension(fileName);
                //delete the old file
                if (!model.Site.IsNew())
                {
                    var oldImage = _service.GetSite().Logo;
                    var oldImagePath = this.Server.MapPath(String.Format("~/user_images/{0}", oldImage));
                    if (System.IO.File.Exists(oldImagePath))
                        System.IO.File.Delete(oldImagePath);
                }
                model.Site.Logo = String.Format("{0}{1}", Guid.NewGuid(), extension);
                //resize
                using(var bitMap =  ImageHelper.Instance().ResizeImage(Request.Files[0].InputStream, 20, 20))
                {
                    var saveTo = this.Server.MapPath(String.Format("~/user_images/{0}", model.Site.Logo));
                    bitMap.Save(saveTo);
                }

            };
            _service.SetSite(model.Site);
            TempData["message"] = "Site settings have been set";
            return RedirectToAction("Index", "Home", new {id = model.NavigationModel.Page.PageNavigation.Id});
        }
Ejemplo n.º 2
0
 public ActionResult Edit(int id)
 {
     var model = new SiteEditViewModel { Site = _service.GetSite() };
     model.NavigationModel = HomeIndexViewModelLoader.Create(id, _service);
     return View(model);
 }