public AdminController() { var conString = string.Empty; conString = Convert.ToString(ConfigurationManager.AppSettings["dbTransferDeskService"]); _manuscriptService = new ManuscriptService(conString, conString); _manuscriptDBRepositoryReadSide = new ManuscriptDBRepositoryReadSide(conString); _JournalRepository = new JournalRepository(conString); journalvm = new JournalVM(); JournalArticleTypeRepository = new JournalArticleTypeRepository(conString); journalarticletypevm = new JournalArticleTypeVM(); _JournalSectionReposistory = new JournalSectionTypeRepository(conString); journalsectionvm = new JournalSectionTypeVM(); }
public ActionResult JournalSectionTypes(JournalSectionTypeVM journalsectiontype) { if (ModelState.IsValid) { var journalidvalue = _JournalSectionReposistory.JournalIDvalue(journalsectiontype.JournalTitleName.Trim()); RegexOptions options = RegexOptions.None; Regex regex = new Regex("[ ]{2,}", options); var sectionname = regex.Replace(journalsectiontype.SectionName, " ").Trim(); if (journalsectiontype.ID != 0) { if (_JournalSectionReposistory.IsJournalSectionTypeAvailable(journalidvalue, journalsectiontype.SectionTypeID, sectionname, journalsectiontype.IsActive)) { string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is updated successfully"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } else { if (_JournalSectionReposistory.IsSectionNameAvailable(sectionname)) { int chksectionid = _JournalSectionReposistory.sectionID(sectionname); if (chksectionid == journalsectiontype.SectionTypeID) { var _JournalSectionAdd = new JournalSections(); _JournalSectionAdd.ID = journalsectiontype.ID; _JournalSectionAdd.JournalID = journalidvalue; _JournalSectionAdd.SectionID = journalsectiontype.SectionTypeID; _JournalSectionAdd.Status = 1; _JournalSectionAdd.IsActive = journalsectiontype.IsActive; _JournalSectionAdd.ModifiedDateTime = System.DateTime.Now; _JournalSectionReposistory.UpdateJournalSection(_JournalSectionAdd); _JournalSectionReposistory.SaveChanges(); string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is updated succesfully"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } else { if (_JournalSectionReposistory.IsSectionTypeAvailable(sectionname, journalidvalue)) { string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is already present"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } else { if (_JournalSectionReposistory.AddJournalSectionData(journalidvalue, chksectionid)) { string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is added succesfully"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } } } } else { _JournalSectionReposistory.AddSectionData(sectionname); var sectionid = _JournalSectionReposistory.sectionID(sectionname); if (_JournalSectionReposistory.AddJournalSectionData(journalidvalue, sectionid)) { var message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is added succesfully"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } } } } else { if (_JournalSectionReposistory.IsSectionTypeAvailable(sectionname, journalidvalue)) { string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is already present"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } else { if (_JournalSectionReposistory.IsSectionNameAvailable(sectionname)) { int sectionid = _JournalSectionReposistory.sectionID(sectionname); if (_JournalSectionReposistory.AddJournalSectionData(journalidvalue, sectionid)) { string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is added succesfully"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } } else { _JournalSectionReposistory.AddSectionData(sectionname); int sectionid = _JournalSectionReposistory.sectionID(sectionname); if (_JournalSectionReposistory.AddJournalSectionData(journalidvalue, sectionid)) { string message = "Record for Section : " + sectionname + " with Journal Title : " + journalsectiontype.JournalTitleName + " is added succesfully"; TempData["msg"] = "<script>alert(\"" + message + "\");</script>"; return(RedirectToAction("JournalSectionTypes", "Admin", journalsectiontype)); } } } } } return(RedirectToAction("JournalSectionTypes", "Admin")); }