// GET: /Edit public ActionResult Edit(int id) { //Set Access Rights ViewData["Access"] = ""; if (hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Access"] = "WriteAccess"; } GDSRequestType gdsRequestType = gdsRequestTypeRepository.GetGDSRequestType(id); //Check Exists if (gdsRequestType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } GDSRequestTypeVM gdsRequestTypeVM = new GDSRequestTypeVM(); gdsRequestTypeVM.GDSRequestType = gdsRequestType; return(View(gdsRequestTypeVM)); }
//Add GDSRequestType public void Add(GDSRequestTypeVM gdsGDSRequestTypeVM) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertGDSRequestType_v1( gdsGDSRequestTypeVM.GDSRequestType.GDSRequestTypeName, adminUserGuid ); }
//Delete GDSRequestType public void Delete(GDSRequestTypeVM gdsRequestTypeVM) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeleteGDSRequestType_v1( gdsRequestTypeVM.GDSRequestType.GDSRequestTypeId, adminUserGuid, gdsRequestTypeVM.GDSRequestType.VersionNumber ); }
public ActionResult Create(GDSRequestTypeVM gdsRequestTypeVM) { //Set Access Rights ViewData["Access"] = ""; if (hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Access"] = "WriteAccess"; } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { TryUpdateModel <GDSRequestTypeVM>(gdsRequestTypeVM, "GDSGDSRequestTypeVM"); } 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")); } try { gdsRequestTypeRepository.Add(gdsRequestTypeVM); } 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")); }
public ActionResult Create() { //Set Access Rights ViewData["Access"] = ""; if (hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Access"] = "WriteAccess"; } GDSRequestTypeVM gdsRequestTypeVM = new GDSRequestTypeVM(); GDSRequestType gdsRequestType = new GDSRequestType(); gdsRequestTypeVM.GDSRequestType = gdsRequestType; return(View(gdsRequestTypeVM)); }
public ActionResult Delete(GDSRequestTypeVM gdsRequestTypeVM, FormCollection collection) { //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Get Item From Database GDSRequestType gdsRequestType = new GDSRequestType(); gdsRequestType = gdsRequestTypeRepository.GetGDSRequestType(gdsRequestTypeVM.GDSRequestType.GDSRequestTypeId); //Check Exists if (gdsRequestType == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Delete Item try { gdsRequestTypeRepository.Delete(gdsRequestTypeVM); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/GDSRequestType.mvc/Delete/" + gdsRequestType.GDSRequestTypeId; 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 Delete(int id) { GDSRequestType gdsRequestType = new GDSRequestType(); gdsRequestType = gdsRequestTypeRepository.GetGDSRequestType(id); //Check Exists if (gdsRequestType == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } GDSRequestTypeVM gdsRequestTypeVM = new GDSRequestTypeVM(); gdsRequestTypeVM.AllowDelete = true; //Attached Items List <GDSRequestTypeReference> gdsRequestTypeReferences = gdsRequestTypeRepository.GetGDSRequestTypeReferences(gdsRequestType.GDSRequestTypeId); if (gdsRequestTypeReferences.Count > 0) { gdsRequestTypeVM.AllowDelete = false; gdsRequestTypeVM.GDSRequestTypeReferences = gdsRequestTypeReferences; } gdsRequestTypeVM.GDSRequestType = gdsRequestType; return(View(gdsRequestTypeVM)); }