// 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")); } ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(id); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Access"] = "WriteAccess"; } ClientAccountAddressVM clientAccountAddressVM = new ClientAccountAddressVM(); clientAccountAddressVM.ClientAccount = clientAccount; clientAccountAddressVM.ClientDetail = clientDetail; Address address = new Address(); clientAccountAddressVM.Address = address; CountryRepository countryRepository = new CountryRepository(); clientAccountAddressVM.Countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName"); MappingQualityRepository mappingQualityRepository = new MappingQualityRepository(); clientAccountAddressVM.MappingQualityCodes = new SelectList(mappingQualityRepository.GetAllMappingQualities().ToList(), "MappingQualityCode", "MappingQualityCode", address.MappingQualityCode); return(View(clientAccountAddressVM)); }
public ActionResult Delete(int id) { ClientDetailAddress clientDetailAddress = new ClientDetailAddress(); clientDetailAddress = clientDetailAddressRepository.GetAddressClientDetail(id); //Check Exists if (clientDetailAddress == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailAddress.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "DeleteGet"; 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); addressRepository.EditForDisplay(address); clientAccountAddressVM.Address = address; return(View(clientAccountAddressVM)); }
// GET: /View public ActionResult View(int id) { ClientDetailAddress clientDetailAddress = new ClientDetailAddress(); clientDetailAddress = clientDetailAddressRepository.GetAddressClientDetail(id); //Check Exists if (clientDetailAddress == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailAddress.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); 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); addressRepository.EditForDisplay(address); clientAccountAddressVM.Address = address; return(View(clientAccountAddressVM)); }
//Get a Page of ClientAccountAddresses /*public CWTPaginatedList<spDesktopDataAdmin_SelectClientDetailAddresses_v1Result> ListClientAccountAddresses(string clientAccountNumber, string sourceSystemCode, int page) * { * string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; * var result = db.spDesktopDataAdmin_SelectClientDetailAddresses_v1(sourceSystemCode, clientAccountNumber, adminUserGuid, page).ToList(); * * //total records for paging * int totalRecords = 0; * if (result.Count() > 0) * { * totalRecords = (int)result.First().RecordCount; * } * * //put into page object * var paginatedView = new CWTPaginatedList<spDesktopDataAdmin_SelectClientDetailAddresses_v1>(result, page, Convert.ToInt32(totalRecords)); * return paginatedView; * } * */ //Add ClientAccountAddress public void Add(ClientAccountAddressVM clientAccountAddressVM) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; /*db.spDesktopDataAdmin_InsertClientAccountAddress_v1( * clientAccountAddressVM.ClientAccount.ClientAccountNumber, * clientAccountAddressVM.ClientAccount.SourceSystemCode, * clientAccountAddressVM.Address.FirstAddressLine, * clientAccountAddressVM.Address.SecondAddressLine, * clientAccountAddressVM.Address.CityName, * clientAccountAddressVM.Address.CountyName, * clientAccountAddressVM.Address.StateProvinceName, * clientAccountAddressVM.Address.LatitudeDecimal, * clientAccountAddressVM.Address.LongitudeDecimal, * clientAccountAddressVM.Address.MappingQualityCode, * clientAccountAddressVM.Address.PostalCode, * clientAccountAddressVM.Address.ReplicatedFromClientMaintenanceFlag, * clientAccountAddressVM.Address.CountryCode, * adminUserGuid * ); * */ }
public ActionResult Edit(ClientAccountAddressVM clientAccountAddressVM) { int clientDetailId = clientAccountAddressVM.ClientDetail.ClientDetailId; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Check Exists if (clientAccount == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { TryUpdateModel <Address>(clientAccountAddressVM.Address, "Address"); } 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 { addressRepository.Edit(clientAccountAddressVM.Address); } 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 = clientDetailId })); }
// 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)); }