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));
        }
Exemplo n.º 2
0
        // GET: /View
        public ActionResult View(int id)
        {
            //Check Exists
            Location location = new Location();

            location = locationRepository.GetLocation(id);
            if (location == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            AddressLocationVM addressLocationVM = new AddressLocationVM();

            addressLocationVM.Location = location;
            addressLocationVM.Address  = new Address();

            Address address = locationRepository.GetLocationAddress(id);

            if (address != null)
            {
                AddressRepository addressRepository = new AddressRepository();
                addressRepository.EditForDisplay(address);
                addressLocationVM.Address = address;
            }

            return(View(addressLocationVM));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            //Check Exists
            Location location = new Location();

            location = locationRepository.GetLocation(id);
            if (location == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

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

            locationRepository.EditForDisplay(location);

            LocationDeleteVM locationDeleteVM = new LocationDeleteVM();

            locationDeleteVM.Address = new Address();

            Address address = locationRepository.GetLocationAddress(id);

            if (address != null)
            {
                AddressRepository addressRepository = new AddressRepository();
                addressRepository.EditForDisplay(address);
                locationDeleteVM.Address = address;
            }

            LocationWizardRepository locationWizardRepository = new LocationWizardRepository();

            locationDeleteVM.Location    = location;
            locationDeleteVM.Teams       = locationWizardRepository.GetLocationTeams(id);
            locationDeleteVM.SystemUsers = locationWizardRepository.GetLocationSystemUsers(id);

            LocationLinkedItemsVM locationLinkedItemsVM = new LocationLinkedItemsVM();

            locationLinkedItemsVM.Location = location;
            locationWizardRepository.AddLinkedItems(locationLinkedItemsVM);
            locationDeleteVM.LinkedItems = locationLinkedItemsVM;

            return(View(locationDeleteVM));
        }
Exemplo n.º 5
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Check Exists
            Location location = new Location();

            location = locationRepository.GetLocation(id);
            if (location == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

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

            AddressLocationVM addressLocationVM = new AddressLocationVM();

            locationRepository.EditForDisplay(location);
            addressLocationVM.Location = location;

            Address address = locationRepository.GetLocationAddress(id);

            if (address != null)
            {
                AddressRepository addressRepository = new AddressRepository();
                addressRepository.EditForDisplay(address);
                addressLocationVM.Address = address;
            }

            CountryRepository countryRepository = new CountryRepository();
            SelectList        countryRegionList = new SelectList(countryRepository.GetCountryRegions(location.CountryRegion.Country.CountryCode).ToList(), "CountryRegionId", "CountryRegionName");

            ViewData["CountryRegions"] = countryRegionList;

            //StateProvince SelectList
            StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();

            addressLocationVM.StateProvinces = new SelectList(stateProvinceRepository.GetStateProvincesByCountryCode(location.CountryCode).ToList(), "StateProvinceCode", "Name", address.StateProvinceCode);

            return(View(addressLocationVM));
        }
Exemplo n.º 6
0
        public ActionResult Delete(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));
        }