Example #1
0
        public ActionResult Edit(SiteModel model, bool continueEditing)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageSites))
            //    return AccessDeniedView();

            var site = _siteService.GetSiteById(model.Id);

            if (site == null)
            {
                //No site found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                site = model.ToEntity(site);
                //ensure we have "/" at the end
                site.Url = site.Url.EnsureEndsWith("/");
                _siteService.UpdateSite(site);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.Sites.Updated"));
                return(continueEditing ? RedirectToAction("Edit", new { id = site.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #2
0
 public ActionResult Create(SiteModel model)
 {
     if (ModelState.IsValid)
     {
         Site pts       = new Site();
         bool checkSave = false;
         pts.CreateDay = DateTime.Now;
         int CurrentUserId = WebMatrix.WebData.WebSecurity.CurrentUserId;
         pts.CreateBy = CurrentUserId;
         pts          = model.ToEntity(pts);
         checkSave    = sitesService.sitesResponsitory.Insert(pts);
         TempData["MessageStatus"] = checkSave;
         TempData["Message"]       = $"Thêm mới điểm {(checkSave ? "" : "không")} thành công";
         return(RedirectToAction("SitesManagement"));
     }
     return(View(model));
 }
        public ActionResult SaveSite(SiteModel model)
        {
            if (ModelState.IsValid)
            {
                var site = _siteRepository.GetById(model.Id);
                //always set IsNew to false when saving
                site.IsNew = false;
                site       = model.ToEntity(site);

                _siteRepository.UpdateAndCommit(site);
                return(new NullJsonResult());
            }
            else
            {
                return(Json(new { Errors = ModelState.Errors().ToHtmlString() }));
            }
        }
Example #4
0
        public ActionResult Update(SiteModel model)
        {
            if (ModelState.IsValid)
            {
                Site pts = sitesService.sitesResponsitory.Single(model.Id);
                if (pts == null)
                {
                    return(RedirectToAction("SitesManagement"));
                }
                bool checkSave = false;
                pts       = model.ToEntity(pts);
                checkSave = sitesService.sitesResponsitory.Update(pts);
                TempData["MessageStatus"] = checkSave;
                TempData["Message"]       = $"Cập nhật điểm {(checkSave ? "" : "không")} thành công";

                return(RedirectToAction("SitesManagement"));
            }
            return(View(model));
        }