//Add Data From Linked Tables for Display public void EditGroupForDisplay(PublicHolidayGroup group) { group.PublicHolidayGroupName = Regex.Replace(group.PublicHolidayGroupName, @"[^\w\-()*]", "-"); fnDesktopDataAdmin_SelectPublicHolidayGroupHierarchy_v1Result hierarchy = GetGroupHierarchy(group.PublicHolidayGroupId); if (hierarchy != null) { HierarchyRepository hierarchyRepository = new HierarchyRepository(); HierarchyGroup hierarchyGroup = hierarchyRepository.GetHierarchyGroup( hierarchy.HierarchyType ?? "", hierarchy.HierarchyCode ?? "", hierarchy.HierarchyName ?? "", hierarchy.TravelerTypeGuid ?? "", hierarchy.TravelerTypeName ?? "", hierarchy.SourceSystemCode ?? "" ); if (hierarchyGroup != null) { group.HierarchyType = hierarchyGroup.HierarchyType; group.HierarchyCode = hierarchyGroup.HierarchyCode; group.HierarchyItem = hierarchyGroup.HierarchyItem; group.ClientSubUnitGuid = hierarchyGroup.ClientSubUnitGuid; group.ClientSubUnitName = hierarchyGroup.ClientSubUnitName; group.TravelerTypeGuid = hierarchyGroup.TravelerTypeGuid; group.TravelerTypeName = hierarchyGroup.TravelerTypeName; group.ClientTopUnitName = hierarchyGroup.ClientTopUnitName; group.SourceSystemCode = hierarchyGroup.SourceSystemCode; } } }
// GET: /Create public ActionResult Create(int id) { PublicHolidayGroup publicHolidayGroup = new PublicHolidayGroup(); publicHolidayGroup = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (publicHolidayGroup == null) { ViewData["ActionMethod"] = "ListGet"; return(View("RecordDoesNotExistError")); } RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPublicHolidayGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } PublicHolidayGroupHolidayDate publicHolidayDate = new PublicHolidayGroupHolidayDate(); publicHolidayDate.PublicHolidayGroupName = publicHolidayGroup.PublicHolidayGroupName; publicHolidayDate.PublicHolidayGroupId = publicHolidayGroup.PublicHolidayGroupId; return(View(publicHolidayDate)); }
// GET: /Edit public ActionResult Edit(int id) { //Get Item From Database PublicHolidayGroup group = new PublicHolidayGroup(); group = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (group == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPublicHolidayGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository(); SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName"); ViewData["HierarchyTypes"] = hierarchyTypesList; publicHolidayGroupRepository.EditGroupForDisplay(group); return(View(group)); }
//Delete Group public void Delete(PublicHolidayGroup group) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeletePublicHolidayGroup_v1( group.PublicHolidayGroupId, adminUserGuid, group.VersionNumber); }
public ActionResult Create(PublicHolidayGroupHolidayDate publicHolidayGroupHolidayDate) { PublicHolidayGroup publicHolidayGroup = new PublicHolidayGroup(); publicHolidayGroup = publicHolidayGroupRepository.GetGroup(publicHolidayGroupHolidayDate.PublicHolidayGroupId); //Check Exists if (publicHolidayGroup == null) { ViewData["ActionMethod"] = "CreatePost"; return(View("RecordDoesNotExistError")); } RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPublicHolidayGroup(publicHolidayGroupHolidayDate.PublicHolidayGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { UpdateModel(publicHolidayGroupHolidayDate); } catch { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } ViewData["Message"] = "ValidationError : " + n; return(View("Error")); } //Database Update try { publicHolidayDateRepository.Add(publicHolidayGroupHolidayDate); } catch (SqlException ex) { LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List", new { id = publicHolidayGroupHolidayDate.PublicHolidayGroupId })); }
//Add Data From Linked Tables for Display public void EditItemForDisplay(PublicHolidayGroupHolidayDate publicHolidayGroupHolidayDate) { PublicHolidayGroupRepository publicHolidayGroupRepository = new PublicHolidayGroupRepository(); PublicHolidayGroup publicHolidayGroup = new PublicHolidayGroup(); publicHolidayGroup = publicHolidayGroupRepository.GetGroup(publicHolidayGroupHolidayDate.PublicHolidayGroupId); if (publicHolidayGroup != null) { publicHolidayGroupHolidayDate.PublicHolidayGroupName = publicHolidayGroup.PublicHolidayGroupName; } }
// GET: /View public ActionResult View(int id) { PublicHolidayGroup group = new PublicHolidayGroup(); group = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (group == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } publicHolidayGroupRepository.EditGroupForDisplay(group); return(View(group)); }
//sortable List public ActionResult List(int id, int?page, string sortField, int?sortOrder) { PublicHolidayGroup publicHolidayGroup = new PublicHolidayGroup(); publicHolidayGroup = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (publicHolidayGroup == null) { ViewData["ActionMethod"] = "ListGet"; return(View("RecordDoesNotExistError")); } ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToPublicHolidayGroup(id)) { ViewData["Access"] = "WriteAccess"; } if (sortField != "PublicHolidayDescription") { sortField = "PublicHolidayDate"; } ViewData["CurrentSortField"] = sortField; if (sortOrder == 1) { ViewData["NewSortOrder"] = 0; ViewData["CurrentSortOrder"] = 1; } else { ViewData["NewSortOrder"] = 1; ViewData["CurrentSortOrder"] = 0; } ViewData["PublicHolidayGroupId"] = publicHolidayGroup.PublicHolidayGroupId; ViewData["PublicHolidayGroupName"] = publicHolidayGroup.PublicHolidayGroupName; //return items var cwtPaginatedList = publicHolidayDateRepository.PagePublicHolidayDates(id, page ?? 1, "", sortField, sortOrder ?? 0); return(View(cwtPaginatedList)); }
//Add Group public void Add(PublicHolidayGroup group) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertPublicHolidayGroup_v1( group.PublicHolidayGroupName, group.EnabledFlag, group.EnabledDate, group.ExpiryDate, group.HierarchyType, group.HierarchyCode, group.TravelerTypeGuid, group.ClientSubUnitGuid, group.SourceSystemCode, adminUserGuid ); }
public ActionResult Delete(int id, FormCollection collection) { //Get Item PublicHolidayGroup group = new PublicHolidayGroup(); group = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (group == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPublicHolidayGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Item try { group.VersionNumber = Int32.Parse(collection["VersionNumber"]); publicHolidayGroupRepository.Delete(group); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/PublicHolidayGroup.mvc/Delete/" + group.PublicHolidayGroupId; return(View("VersionError")); } LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List")); }
// GET: /Create public ActionResult Create() { //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } TripTypeRepository tripTypeRepository = new TripTypeRepository(); SelectList tripTypesList = new SelectList(tripTypeRepository.GetAllTripTypes().ToList(), "TripTypeId", "TripTypeDescription"); ViewData["TripTypes"] = tripTypesList; TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository(); SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName"); ViewData["HierarchyTypes"] = hierarchyTypesList; PublicHolidayGroup group = new PublicHolidayGroup(); return(View(group)); }
public ActionResult Delete(int id) { //Get Item From Database PublicHolidayGroup group = new PublicHolidayGroup(); group = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (group == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPublicHolidayGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } publicHolidayGroupRepository.EditGroupForDisplay(group); return(View(group)); }
public ActionResult Edit(int id, FormCollection collection) { //Get Item From Database PublicHolidayGroup group = new PublicHolidayGroup(); group = publicHolidayGroupRepository.GetGroup(id); //Check Exists if (group == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Check Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPublicHolidayGroup(id)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model From Form + Validate against DB try { UpdateModel(group); } catch { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } ViewData["Message"] = "ValidationError : " + n; return(View("Error")); } //ClientSubUnitTravelerType has extra field string hierarchyCode = group.HierarchyCode; if (group.HierarchyType == "ClientSubUnitTravelerType") { group.ClientSubUnitGuid = hierarchyCode; //ClientSubUnitTravelerType has 2 primarykeys } //Check Access Rights to PolicyGroup HierarchyRepository hierarchyRepository = new HierarchyRepository(); if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, hierarchyCode, group.SourceSystemCode, groupName)) { ViewData["Message"] = "You cannot add to this hierarchy item"; return(View("Error")); } //Database Update try { publicHolidayGroupRepository.Edit(group); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/PublicHolidayGroup.mvc/Edit/" + group.PublicHolidayGroupId.ToString();; return(View("VersionError")); } LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List")); }
public ActionResult Create(PublicHolidayGroup group) { //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Check Access Rights to Domain Hierarchy if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, group.HierarchyCode, group.SourceSystemCode, groupName)) { ViewData["Message"] = "You cannot add to this hierarchy item"; return(View("Error")); } //Update Model From Form + Validate against DB try { UpdateModel(group); } catch { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } ViewData["Message"] = "ValidationError : " + n; return(View("Error")); } //ClientSubUnitTravelerType has extra field string hierarchyCode = group.HierarchyCode; if (group.HierarchyType == "ClientSubUnitTravelerType") { group.ClientSubUnitGuid = hierarchyCode; //ClientSubUnitTravelerType has 2 primarykeys } //Database Update try { publicHolidayGroupRepository.Add(group); } catch (SqlException ex) { //Non-Unique Name if (ex.Message == "NonUniqueName") { return(View("NonUniqueNameError")); } LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } ViewData["NewSortOrder"] = 0; return(RedirectToAction("List")); }