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;
            ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit();

            clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId);

            //Check Exists
            if (clientDetailClientTopUnit == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid;


            ClientTopUnit clientTopUnit = new ClientTopUnit();

            clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid);

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientTopUnit(clientTopUnitGuid))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ClientTopUnitAddressVM clientTopUnitAddressVM = new ClientTopUnitAddressVM();

            clientTopUnitAddressVM.ClientTopUnit = clientTopUnit;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(clientDetailId);
            clientTopUnitAddressVM.ClientDetail = clientDetail;

            Address address = new Address();

            address = addressRepository.GetAddress(clientDetailAddress.AddressId);
            addressRepository.EditForDisplay(address);
            clientTopUnitAddressVM.Address = address;

            return(View(clientTopUnitAddressVM));
        }
        // 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;
            ClientDetailClientSubUnitTravelerType clientDetailClientSubUnitTravelerType = new ClientDetailClientSubUnitTravelerType();

            clientDetailClientSubUnitTravelerType = clientDetailClientSubUnitTravelerTypeRepository.GetClientDetailClientSubUnitTravelerType(clientDetailId);

            //Check Exists
            if (clientDetailClientSubUnitTravelerType == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            string csu = clientDetailClientSubUnitTravelerType.ClientSubUnitGuid;
            string tt  = clientDetailClientSubUnitTravelerType.TravelerTypeGuid;


            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu);

            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);
            addressRepository.EditForDisplay(address);
            clientSubUnitTravelerTypeAddressVM.Address = address;

            return(View(clientSubUnitTravelerTypeAddressVM));
        }
        // 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;
            ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit();

            clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId);

            //Check Exists
            if (clientDetailClientTopUnit == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid;


            ClientTopUnit clientTopUnit = new ClientTopUnit();

            clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid);

            ClientTopUnitAddressVM clientTopUnitAddressVM = new ClientTopUnitAddressVM();

            clientTopUnitAddressVM.ClientTopUnit = clientTopUnit;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(clientDetailId);
            clientTopUnitAddressVM.ClientDetail = clientDetail;

            Address address = new Address();

            address = addressRepository.GetAddress(clientDetailAddress.AddressId);
            addressRepository.EditForDisplay(address);
            clientTopUnitAddressVM.Address = address;

            return(View(clientTopUnitAddressVM));
        }
        // 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));
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            ClientDetailAddress clientDetailAddress = new ClientDetailAddress();

            clientDetailAddress = clientDetailAddressRepository.GetAddressClientDetail(id);

            //Check Exists
            if (clientDetailAddress == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            int clientDetailId = clientDetailAddress.ClientDetailId;
            ClientDetailClientSubUnitTravelerType clientDetailClientSubUnitTravelerType = new ClientDetailClientSubUnitTravelerType();

            clientDetailClientSubUnitTravelerType = clientDetailClientSubUnitTravelerTypeRepository.GetClientDetailClientSubUnitTravelerType(clientDetailId);

            //Check Exists
            if (clientDetailClientSubUnitTravelerType == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                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"));
            }

            Address address = new Address();

            address = addressRepository.GetAddress(id);

            //Delete Item
            try
            {
                address.VersionNumber = Int32.Parse(collection["Address.VersionNumber"]);
                addressRepository.Delete(address);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ClientSubUnitAddress.mvc/Delete/" + id.ToString();
                    return(View("VersionError"));
                }
                //Generic Error
                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;
            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));
        }
Beispiel #7
0
        // GET: /View
        public ActionResult View(string csu, 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;
            ClientDetailTravelerType clientDetailTravelerType = new ClientDetailTravelerType();

            clientDetailTravelerType = clientDetailTravelerTypeRepository.GetClientDetailTravelerType(clientDetailId);

            //Check Exists
            if (clientDetailTravelerType == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            string tt = clientDetailTravelerType.TravelerTypeGuid;
            ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType();

            clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt);

            //Check Exists
            if (clientDetailTravelerType == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientSubUnit(csu))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            TravelerTypeAddressVM travelerTypeAddressVM = new TravelerTypeAddressVM();

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu);
            travelerTypeAddressVM.ClientSubUnit = clientSubUnit;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(clientDetailId);
            travelerTypeAddressVM.ClientDetail = clientDetail;

            TravelerType travelerType = new TravelerType();

            travelerType = travelerTypeRepository.GetTravelerType(tt);
            travelerTypeAddressVM.TravelerType = travelerType;

            Address address = new Address();

            address = addressRepository.GetAddress(clientDetailAddress.AddressId);
            addressRepository.EditForDisplay(address);
            travelerTypeAddressVM.Address = address;

            return(View(travelerTypeAddressVM));
        }
        // 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));
        }