public IActionResult OnGet(int sectionTextId, int documentSectionId) { //Alwayas Initialize DocumentSectionTextObj = new Models.DocumentSectionText(); SectionList = _unitOfWork.DocumentSection.GetListForDropDown(); //Adding to a specified section from documents page, preserve section selection. DocumentSection = _unitOfWork.DocumentSection.GetFirstOrDefault(s => s.Id == documentSectionId); if (DocumentSection != null) { DocumentSectionTextObj.DocumentSectionId = DocumentSection.Id; } //Existing (edit) if (sectionTextId != 0) { //Get existing DocumentSectionTextObj = _unitOfWork.DocumentSectionText.GetFirstOrDefault(t => t.Id == sectionTextId); if (DocumentSectionTextObj == null) { return(RedirectToPage("/Home/Documents/Index")); } } return(Page()); }
public IActionResult OnGet(int sectionId, int documentCategoryId) { //Alwayas Initialize DocumentSectionObj = new Models.DocumentSection(); CategoryList = _unitOfWork.DocumentCategory.GetListForDropDown(); //Adding new from documents page (selected category preserved) if (documentCategoryId != 0) { //Get existing DocumentSectionObj.DocumentCategory = _unitOfWork.DocumentCategory.GetFirstOrDefault(c => c.Id == documentCategoryId); if (DocumentSectionObj.DocumentCategory == null) { return(RedirectToPage("/Home/Documents/Index")); } else { DocumentSectionObj.DocumentCategoryId = DocumentSectionObj.DocumentCategory.Id; } } //Existing (edit) else if (sectionId != 0) { //Get existing DocumentSectionObj = _unitOfWork.DocumentSection.GetFirstOrDefault(s => s.Id == sectionId); if (DocumentSectionObj == null) { return(RedirectToPage("/Home/Documents/Index")); } } return(Page()); }