// GET: /Create public ActionResult Create(int id) { ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit(); clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(id); //Check Exists if (clientDetailClientTopUnit == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid; ClientTopUnit clientTopUnit = new ClientTopUnit(); clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid); //Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToClientTopUnit(clientTopUnitGuid)) { ViewData["Access"] = "WriteAccess"; } ClientTopUnitAddressVM clientTopUnitAddressVM = new ClientTopUnitAddressVM(); clientTopUnitAddressVM.ClientTopUnit = clientTopUnit; clientTopUnitAddressVM.ClientDetail = clientDetail; Address address = new Address(); clientTopUnitAddressVM.Address = address; CountryRepository countryRepository = new CountryRepository(); clientTopUnitAddressVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName"); MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); clientTopUnitAddressVM.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", address.MappingQualityCode); return(View(clientTopUnitAddressVM)); }
public ActionResult LocationDetailsScreen(int locationId = 0) { if (!hierarchyRepository.AdminHasDomainWriteAccess("Location")) { return(PartialView("Error", "You do not have access to this item")); } Location location = new Location(); Address address = new Address(); CountryRepository countryRepository = new CountryRepository(); if (locationId > 0) { location = locationRepository.GetLocation(locationId); //Check Exists if (location == null) { return(PartialView("Error", "Location Does Not Exist")); } //get Address address = locationRepository.GetLocationAddress(locationId); AddressRepository addressRepository = new AddressRepository(); addressRepository.EditForDisplay(address); //add linked information locationRepository.EditForDisplay(location); } LocationWizardVM locationWizardViewModel = new LocationWizardVM(); locationWizardViewModel.Location = location; locationWizardViewModel.Address = address; locationWizardViewModel.SystemUserCount = locationWizardRepository.GetLocationSystemUsers(locationId).Count; MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); if (locationWizardViewModel.Address != null) { locationWizardViewModel.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", locationWizardViewModel.Address.MappingQualityCode); } else { locationWizardViewModel.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode"); } //StateProvince SelectList StateProvinceRepository stateProvinceRepository = new StateProvinceRepository(); locationWizardViewModel.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(location.CountryCode).ToList(), "StateProvinceCode", "Name", address.StateProvinceCode); return(PartialView("LocationDetailsScreen", locationWizardViewModel)); }
// GET: /Edit public ActionResult Edit(int id) { ClientDetailAddress clientDetailAddress = new ClientDetailAddress(); clientDetailAddress = clientDetailAddressRepository.GetAddressClientDetail(id); //Check Exists if (clientDetailAddress == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailAddress.ClientDetailId; ClientDetailClientSubUnitTravelerType clientDetailClientSubUnitTravelerType = new ClientDetailClientSubUnitTravelerType(); clientDetailClientSubUnitTravelerType = clientDetailClientSubUnitTravelerTypeRepository.GetClientDetailClientSubUnitTravelerType(clientDetailId); //Check Exists if (clientDetailClientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } string csu = clientDetailClientSubUnitTravelerType.ClientSubUnitGuid; string tt = clientDetailClientSubUnitTravelerType.TravelerTypeGuid; ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientSubUnitTravelerTypeAddressVM clientSubUnitTravelerTypeAddressVM = new ClientSubUnitTravelerTypeAddressVM(); clientSubUnitTravelerTypeAddressVM.ClientSubUnit = clientSubUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientSubUnitTravelerTypeAddressVM.ClientDetail = clientDetail; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); clientSubUnitTravelerTypeAddressVM.TravelerType = travelerType; Address address = new Address(); address = addressRepository.GetAddress(clientDetailAddress.AddressId); clientSubUnitTravelerTypeAddressVM.Address = address; CountryRepository countryRepository = new CountryRepository(); clientSubUnitTravelerTypeAddressVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName", address.CountryCode); MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); clientSubUnitTravelerTypeAddressVM.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", address.MappingQualityCode); return(View(clientSubUnitTravelerTypeAddressVM)); }
// GET: /Create public ActionResult Create(int id, string csu, string tt) { ClientDetailTravelerType clientDetailTravelerType = new ClientDetailTravelerType(); clientDetailTravelerType = clientDetailTravelerTypeRepository.GetClientDetailTravelerType(id); //Check Exists if (clientDetailTravelerType == null) { ViewData["ActionMethod"] = "ListSubMenu"; return(View("RecordDoesNotExistError")); } ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType(); clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt); //Check Exists if (clientDetailTravelerType == null) { ViewData["ActionMethod"] = "ListSubMenu"; return(View("RecordDoesNotExistError")); } //Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToClientSubUnit(csu)) { ViewData["Access"] = "WriteAccess"; } TravelerTypeAddressVM travelerTypeAddressVM = new TravelerTypeAddressVM(); ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); travelerTypeAddressVM.ClientSubUnit = clientSubUnit; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); travelerTypeAddressVM.ClientDetail = clientDetail; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); travelerTypeAddressVM.TravelerType = travelerType; Address address = new Address(); travelerTypeAddressVM.Address = address; CountryRepository countryRepository = new CountryRepository(); travelerTypeAddressVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName"); MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); travelerTypeAddressVM.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", address.MappingQualityCode); return(View(travelerTypeAddressVM)); }
public ActionResult ValidateLocation(LocationWizardVM locationWizardViewModel) { int locationId = 0; if (locationWizardViewModel.Location != null) { locationId = locationWizardViewModel.Location.LocationId; } //Validate Team data against Table if (!ModelState.IsValid) { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } //Need to repopulate List MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); locationWizardViewModel.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", locationWizardViewModel.Address.MappingQualityCode);; locationWizardViewModel.SystemUserCount = locationWizardRepository.GetLocationSystemUsers(locationId).Count; //StateProvince SelectList StateProvinceRepository stateProvinceRepository = new StateProvinceRepository(); locationWizardViewModel.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(locationWizardViewModel.Location.CountryCode).ToList(), "StateProvinceCode", "Name", locationWizardViewModel.Address.StateProvinceCode); //Validation Error - retrun to Details Screen return(Json(new WizardJSONResponse { html = ControllerExtension.RenderPartialViewToString(this, "LocationDetailsScreen", locationWizardViewModel), message = "ValidationError (" + n + ")", success = false })); } //Location Location location = new Location(); location = locationWizardViewModel.Location; LocationSystemUsersVM locationUsersScreen = new LocationSystemUsersVM(); locationUsersScreen.Location = locationWizardViewModel.Location; // Systemusers List <spDDAWizard_SelectLocationSystemUsers_v1Result> systemUsers = new List <spDDAWizard_SelectLocationSystemUsers_v1Result>(); systemUsers = locationWizardRepository.GetLocationSystemUsers(location.LocationId); locationUsersScreen.SystemUsers = systemUsers; //Show Location's systemUsers return(Json(new WizardJSONResponse { html = ControllerExtension.RenderPartialViewToString(this, "LocationUsersScreen", locationUsersScreen), message = "Success", success = true })); }
// GET: /Edit public ActionResult Edit(int id) { ClientDetailAddress clientDetailAddress = new ClientDetailAddress(); clientDetailAddress = clientDetailAddressRepository.GetAddressClientDetail(id); //Check Exists if (clientDetailAddress == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailAddress.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientAccountAddressVM clientAccountAddressVM = new ClientAccountAddressVM(); clientAccountAddressVM.ClientAccount = clientAccount; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientAccountAddressVM.ClientDetail = clientDetail; Address address = new Address(); address = addressRepository.GetAddress(clientDetailAddress.AddressId); clientAccountAddressVM.Address = address; CountryRepository countryRepository = new CountryRepository(); clientAccountAddressVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName", address.CountryCode); MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); clientAccountAddressVM.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", address.MappingQualityCode); return(View(clientAccountAddressVM)); }