public IActionResult Delete(int id, int pageRouteVersionId) { PageSectionVersion pageSectionVersion = _dynamicPageSectionVersionRepository.Delete(id, pageRouteVersionId); if (pageSectionVersion != null) { if (pageSectionVersion.PageRouteVersion.StatusId != (int)RequestStatus.Draft) { _pageRouteVersionRepository.ChangeStatus(pageSectionVersion.PageRouteVersionId, RequestStatus.Draft); } _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Delete, "Dynamic Page > " + ViewBag.DynamicPageName + " > Sections > Delete", pageSectionVersion.EnTitle); TempData[notificationMessageKey] = ToasrMessages.DeleteSuccess; TempData[notificationTypeKey] = notificationSuccess; return(Json(new { })); } _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Delete, "Dynamic Page > " + ViewBag.DynamicPageName + " > Sections > Warning in Delete", pageSectionVersion.EnTitle); TempData[notificationMessageKey] = "Error has been occurred."; TempData[notificationTypeKey] = notificationError; return(Json(new { })); }
public IActionResult Edit(SectionCardEditViewModel sectionCardViewModel) { sectionCardViewModel.EnDescription.ValidateHtml("EnDescription", ModelState); sectionCardViewModel.ArDescription.ValidateHtml("ArDescription", ModelState); if (ModelState.IsValid) { PageSectionCardVersion sectionCardVersion = sectionCardViewModel.MapToSectionCardVersion(); string oldPhotoPath = null; string oldFilePath = null; if (sectionCardViewModel.Photo != null) { oldPhotoPath = sectionCardVersion.ImageUrl; sectionCardVersion.ImageUrl = _fileService.UploadImageUrlNew(sectionCardViewModel.Photo); } if (sectionCardViewModel.File != null) { oldFilePath = sectionCardVersion.FileUrl; sectionCardVersion.FileUrl = _fileService.UploadFileUrlNew(sectionCardViewModel.File); } var subApplicationName = _configuration.GetSection("SubApplicationName").Value; if (!string.IsNullOrWhiteSpace(subApplicationName)) { sectionCardViewModel.FileUrl = sectionCardViewModel.FileUrl.ToLower().Replace(subApplicationName.ToLower(), ""); sectionCardVersion.FileUrl = sectionCardViewModel.FileUrl; } PageSectionCardVersion newSectionCardVersion = _sectionCardVersionRepository.Update(sectionCardVersion, sectionCardViewModel.PageRouteVersionId); if (newSectionCardVersion != null) { if (newSectionCardVersion.PageSectionVersion.PageRouteVersion.StatusId != (int)RequestStatus.Draft) { _pageRouteVersionRepository.ChangeStatus(newSectionCardVersion.PageSectionVersion.PageRouteVersionId, RequestStatus.Draft); } if (oldPhotoPath != null) { _fileService.RemoveImage(oldPhotoPath); } if (oldFilePath != null) { _fileService.RemoveFile(oldFilePath); } _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Update, "Dynamic Page > Card > Warning", newSectionCardVersion.EnTitle); _toastNotification.AddSuccessToastMessage(ToasrMessages.EditSuccess); return(RedirectToAction("Index", new { id = newSectionCardVersion.PageSectionVersionId, pageRouteVersionId = newSectionCardVersion.PageSectionVersion.PageRouteVersionId })); } else { _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Warning, "Dynamic Page > Card > Warning", sectionCardVersion.EnTitle); _toastNotification.AddErrorToastMessage(ToasrMessages.warning); } } return(View(sectionCardViewModel)); }