public ActionResult Edit(BlogModel model, FormCollection frm, bool continueEditing) { if (!_permissionService.Authorize("ManageBlogs")) { return(AccessDeniedView()); } var user = _userContext.CurrentUser; var newBlogPictures = new List <BlogPicture>(); // Check for duplicate blog, if any var _blog = _blogService.GetBlogByName(model.Name); if (_blog != null && _blog.Id != model.Id) { ModelState.AddModelError("Name", "An Blog with the same name already exists. Please choose a different name."); } if (ModelState.IsValid) { var blogItem = _blogService.GetBlogById(model.Id); if (blogItem == null || blogItem.IsDeleted) { return(RedirectToAction("List")); } blogItem = model.ToEntity(blogItem); blogItem.ModifiedOn = DateTime.Now; blogItem.UserId = user.Id; _blogService.Update(blogItem); // Save URL Record model.SystemName = blogItem.ValidateSystemName(model.SystemName, model.Name, true); _urlService.SaveSlug(blogItem, model.SystemName); } else { model.AvailableAcadmicYears = _smsService.GetAllAcadmicYears().Select(x => new SelectListItem() { Text = x.Name.Trim(), Value = x.Id.ToString(), Selected = x.IsActive }).ToList(); ErrorNotification("An error occured while updating blog. Please try again."); return(View(model)); } SuccessNotification("Blog updated successfully."); if (continueEditing) { return(RedirectToAction("Edit", new { id = model.Id })); } return(RedirectToAction("List")); }