//Create ThirdPartyUser public void Add(ThirdPartyUserVM thirdPartyUserVM) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; string computerName = logRepository.GetComputerName(); db.spDesktopDataAdmin_InsertThirdPartyUser_v1( thirdPartyUserVM.ThirdPartyUser.TISUserId, thirdPartyUserVM.ThirdPartyUser.ThirdPartyName, thirdPartyUserVM.ThirdPartyUser.LastName, thirdPartyUserVM.ThirdPartyUser.FirstName, thirdPartyUserVM.ThirdPartyUser.Email, thirdPartyUserVM.ThirdPartyUser.IsActiveFlagNonNullable, thirdPartyUserVM.ThirdPartyUser.CubaBookingAllowanceIndicatorNonNullable, thirdPartyUserVM.ThirdPartyUser.MilitaryAndGovernmentUserFlagNonNullable, thirdPartyUserVM.ThirdPartyUser.RoboticUserFlagNonNullable, thirdPartyUserVM.ThirdPartyUser.CWTManager, thirdPartyUserVM.ThirdPartyUser.ThirdPartyUserTypeId, thirdPartyUserVM.ThirdPartyUser.ClientTopUnitGuid, thirdPartyUserVM.ThirdPartyUser.ClientSubUnitGuid, thirdPartyUserVM.ThirdPartyUser.PartnerId, thirdPartyUserVM.ThirdPartyUser.GDSThirdPartyVendorId, thirdPartyUserVM.ThirdPartyUser.FirstAddressLine, thirdPartyUserVM.ThirdPartyUser.SecondAddressLine, thirdPartyUserVM.ThirdPartyUser.CityName, thirdPartyUserVM.ThirdPartyUser.PostalCode, thirdPartyUserVM.ThirdPartyUser.CountryCode, thirdPartyUserVM.ThirdPartyUser.StateProvinceCode, thirdPartyUserVM.ThirdPartyUser.Phone, thirdPartyUserVM.ThirdPartyUser.InternalRemark, adminUserGuid, Settings.ApplicationName(), Settings.ApplicationVersion(), computerName ); }
public ActionResult UnDelete(int id) { ThirdPartyUser thirdPartyUser = new ThirdPartyUser(); thirdPartyUser = thirdPartyUserRepository.GetThirdPartyUser(id); //Check Exists if (thirdPartyUser == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(thirdPartyGroupName) && !hierarchyRepository.AdminHasDomainWriteAccess(governmentGroupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ThirdPartyUserVM thirdPartyUserVM = new ThirdPartyUserVM(); thirdPartyUserRepository.EditForDisplay(thirdPartyUser); thirdPartyUserVM.ThirdPartyUser = thirdPartyUser; return(View(thirdPartyUserVM)); }
//UpdateDeletedStatus ThirdPartyUser public void UpdateDeletedStatus(ThirdPartyUserVM thirdPartyUserVM) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_UpdateThirdPartyUserDeletedStatus_v1( thirdPartyUserVM.ThirdPartyUser.ThirdPartyUserId, thirdPartyUserVM.ThirdPartyUser.DeletedFlag, adminUserGuid, thirdPartyUserVM.ThirdPartyUser.VersionNumber ); }
public ActionResult Create(ThirdPartyUserVM thirdPartyUserVM) { //Set Access Rights ViewData["Access"] = ""; if (hierarchyRepository.AdminHasDomainWriteAccess(thirdPartyGroupName) || hierarchyRepository.AdminHasDomainWriteAccess(governmentGroupName)) { ViewData["Access"] = "WriteAccess"; } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(thirdPartyGroupName) && !hierarchyRepository.AdminHasDomainWriteAccess(governmentGroupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { TryUpdateModel <ThirdPartyUserVM>(thirdPartyUserVM, "ThirdPartyUserVM"); } 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 { thirdPartyUserRepository.Add(thirdPartyUserVM); } 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("ListUnDeleted")); }
public ActionResult UnDelete(ThirdPartyUserVM thirdPartyUserVM, FormCollection collection) { //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(thirdPartyGroupName) && !hierarchyRepository.AdminHasDomainWriteAccess(governmentGroupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Get Item From Database ThirdPartyUser thirdPartyUser = new ThirdPartyUser(); thirdPartyUser = thirdPartyUserRepository.GetThirdPartyUser(thirdPartyUserVM.ThirdPartyUser.ThirdPartyUserId); //Check Exists if (thirdPartyUser == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Delete Item try { thirdPartyUserVM.ThirdPartyUser.DeletedFlag = false; thirdPartyUserRepository.UpdateDeletedStatus(thirdPartyUserVM); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/ThirdPartyUser.mvc/Delete/" + thirdPartyUser.ThirdPartyUserId; 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("ListDeleted")); }
// GET: /Edit public ActionResult Edit(int id) { ThirdPartyUser thirdPartyUser = new ThirdPartyUser(); thirdPartyUser = thirdPartyUserRepository.GetThirdPartyUser(id); //Check Exists if (thirdPartyUser == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } ThirdPartyUserVM thirdPartyUserVM = new ThirdPartyUserVM(); //CubaPseudoCityOrOfficeFlag //Only a user with the Compliance Administrator for Global can check or uncheck this box ViewData["ComplianceAdministratorAccess"] = ""; if (rolesRepository.HasWriteAccessToThirdPartyUserCubaBookingAllowanceIndicator()) { ViewData["ComplianceAdministratorAccess"] = "WriteAccess"; } //GovernmentPseudoCityOrOfficeFlag //Only a user with the GDS Government Administrator role for Global can check or uncheck this box ViewData["GDSGovernmentAdministratorAccess"] = ""; if (rolesRepository.HasWriteAccessToThirdPartyUserMilitaryAndGovernmentUserFlag()) { ViewData["GDSGovernmentAdministratorAccess"] = "WriteAccess"; } //ThirdPartyUserTypes thirdPartyUserVM.ThirdPartyUserTypes = new SelectList(thirdPartyUserTypeRepository.GetAllThirdPartyUserTypes().ToList(), "ThirdPartyUserTypeId", "ThirdPartyUserTypeName", thirdPartyUser.ThirdPartyUserTypeId); //GDSThirdPartyVendors thirdPartyUserVM.GDSThirdPartyVendors = new SelectList(gdsThirdPartyVendorRepository.GetAllGDSThirdPartyVendors().ToList(), "GDSThirdPartyVendorId", "GDSThirdPartyVendorName", thirdPartyUser.GDSThirdPartyVendorId); //StateProvinces thirdPartyUserVM.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(thirdPartyUser.CountryCode).ToList(), "StateProvinceCode", "Name", thirdPartyUser.StateProvinceCode); thirdPartyUserRepository.EditForDisplay(thirdPartyUser); thirdPartyUserVM.ThirdPartyUser = thirdPartyUser; return(View(thirdPartyUserVM)); }
public ActionResult Create() { //Set Access Rights ViewData["Access"] = ""; if (hierarchyRepository.AdminHasDomainWriteAccess(thirdPartyGroupName) || hierarchyRepository.AdminHasDomainWriteAccess(governmentGroupName)) { ViewData["Access"] = "WriteAccess"; } ThirdPartyUserVM thirdPartyUserVM = new ThirdPartyUserVM(); ThirdPartyUser thirdPartyUser = new ThirdPartyUser(); thirdPartyUser.IsActiveFlagNonNullable = true; thirdPartyUser.RoboticUserFlagNonNullable = false; thirdPartyUserVM.ThirdPartyUser = thirdPartyUser; //CubaPseudoCityOrOfficeFlag //Only a user with the Compliance Administrator for Global can check or uncheck this box ViewData["ComplianceAdministratorAccess"] = ""; if (rolesRepository.HasWriteAccessToThirdPartyUserCubaBookingAllowanceIndicator()) { ViewData["ComplianceAdministratorAccess"] = "WriteAccess"; } //GovernmentPseudoCityOrOfficeFlag //Only a user with the GDS Government Administrator role for Global can check or uncheck this box ViewData["GDSGovernmentAdministratorAccess"] = ""; if (rolesRepository.HasWriteAccessToThirdPartyUserMilitaryAndGovernmentUserFlag()) { ViewData["GDSGovernmentAdministratorAccess"] = "WriteAccess"; } //ThirdPartyUserTypes thirdPartyUserVM.ThirdPartyUserTypes = new SelectList(thirdPartyUserTypeRepository.GetAllThirdPartyUserTypes().ToList(), "ThirdPartyUserTypeId", "ThirdPartyUserTypeName"); //GDSThirdPartyVendors thirdPartyUserVM.GDSThirdPartyVendors = new SelectList(gdsThirdPartyVendorRepository.GetAllGDSThirdPartyVendors().ToList(), "GDSThirdPartyVendorId", "GDSThirdPartyVendorName"); //StateProvinces thirdPartyUserVM.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(thirdPartyUser.CountryCode).ToList(), "StateProvinceCode", "Name"); return(View(thirdPartyUserVM)); }
public ActionResult Edit(ThirdPartyUserVM thirdPartyUserVM) { //Set Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(thirdPartyGroupName) && !hierarchyRepository.AdminHasDomainWriteAccess(governmentGroupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Only a user with the correct roles can change these options if (!rolesRepository.HasWriteAccessToThirdPartyUserCubaBookingAllowanceIndicator() || !rolesRepository.HasWriteAccessToThirdPartyUserMilitaryAndGovernmentUserFlag()) { ThirdPartyUser thirdPartyUser = new ThirdPartyUser(); thirdPartyUser = thirdPartyUserRepository.GetThirdPartyUser(thirdPartyUserVM.ThirdPartyUser.ThirdPartyUserId); //Check Exists if (thirdPartyUser == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } thirdPartyUserRepository.EditForDisplay(thirdPartyUser); //CubaPseudoCityOrOfficeFlag //Only a user with the Compliance Administrator for Global can check or uncheck this box if (!rolesRepository.HasWriteAccessToThirdPartyUserCubaBookingAllowanceIndicator()) { thirdPartyUserVM.ThirdPartyUser.CubaBookingAllowanceIndicatorNonNullable = thirdPartyUser.CubaBookingAllowanceIndicatorNonNullable; } //GovernmentPseudoCityOrOfficeFlag //Only a user with the GDS Government Administrator role for Global can check or uncheck this box if (!rolesRepository.HasWriteAccessToThirdPartyUserMilitaryAndGovernmentUserFlag()) { thirdPartyUserVM.ThirdPartyUser.MilitaryAndGovernmentUserFlagNonNullable = thirdPartyUser.MilitaryAndGovernmentUserFlagNonNullable; } } //Update Model from Form try { TryUpdateModel <ThirdPartyUser>(thirdPartyUserVM.ThirdPartyUser, "ThirdPartyUser"); } 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 { thirdPartyUserRepository.Update(thirdPartyUserVM); } 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")); } string redirectAction = (thirdPartyUserVM.ThirdPartyUser.DeletedFlag == true) ? "ListDeleted" : "ListUnDeleted"; return(RedirectToAction(redirectAction)); }