示例#1
0
        //Show Popup When a User tries To Delete (PART OF STEP 2)- Returns PartialView
        public ActionResult ShowConfirmDelete(int locationId = 0)
        {
            //Access to Locations
            if (!hierarchyRepository.AdminHasDomainWriteAccess("Location"))
            {
                return(PartialView("Error", "You do not have access to this item"));
            }

            Location location = new Location();

            location = locationRepository.GetLocation(locationId);

            //Check Exists
            if (location == null)
            {
                return(PartialView("Error", "Location Does Not Exist"));
            }
            //Access to this Location
            if (!rolesRepository.HasWriteAccessToLocation(locationId))
            {
                return(PartialView("Error", "You do not have access to this item"));
            }
            LocationSystemUsersVM locationUsersScreenViewModel = new LocationSystemUsersVM();

            locationUsersScreenViewModel.SystemUsers = locationWizardRepository.GetLocationSystemUsers(locationId);
            locationUsersScreenViewModel.Location    = location;

            List <spDDAWizard_SelectLocationTeams_v1Result> teams = new List <spDDAWizard_SelectLocationTeams_v1Result>();

            teams = locationWizardRepository.GetLocationTeams(locationId);
            locationUsersScreenViewModel.LocationTeamCount = teams.Count();

            return(PartialView("ConfirmDeletePopup", locationUsersScreenViewModel));
        }
示例#2
0
        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
            }));
        }