Пример #1
0
        public ActionResult Create()
        {
            CreateClientViewModel model = new CreateClientViewModel();
            var allEthnicities          = EthnicityManager.GetAll();
            var allDemographics         = DemographicManager.GetAll();
            var allAbuseTypes           = AbuseTypeManager.GetAll();
            var allCounties             = CountyManager.GetAll();
            var allServiceCounties      = CountyManager.GetInServiceArea();
            var allTypes    = TypeManager.GetAll();
            var allStates   = StateManager.GetAll();
            var allGenders  = GenderManager.GetAll();
            var allStatuses = StatusManager.GetAll();

            var checkBoxListItems          = new List <CheckBoxListItem>();
            var abuseTypeCheckBoxListItems = new List <CheckBoxListItem>();

            model.Ethnicities       = allEthnicities;
            model.CountyOfResidence = allCounties;
            model.CountyOfIncident  = allServiceCounties;
            model.Genders           = allGenders;
            model.Types             = allTypes;
            model.States            = allStates;
            model.Statuses          = allStatuses;

            foreach (var demographic in allDemographics)
            {
                checkBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = demographic.DemographicId,
                    Display   = demographic.DemographicName,
                    IsChecked = false //On the add view, no genres will be selected by default
                });
            }

            model.Demographics = checkBoxListItems;

            foreach (var abuseType in allAbuseTypes)
            {
                abuseTypeCheckBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = abuseType.AbuseTypeId,
                    Display   = abuseType.AbuseTypeName,
                    IsChecked = false //On the add view, no genres will be selected by default
                });
            }

            model.AbuseTypes = abuseTypeCheckBoxListItems;

            return(View(model));
        }
Пример #2
0
        public ActionResult Details(int id)
        {
            var client = ClientManager.GetById(id);
            var model  = new EditClientViewModel()
            {
                ID = client.ID,
                ClientFirstName     = client.ClientFirstName,
                ClientMiddleInitial = client.ClientMiddleInitial,
                ClientLastName      = client.ClientLastName,
                DateofBirth         = client.DateofBirth,
                DateofFirstContact  = client.DateofFirstContact,
                Address1            = client.Address1,
                Address2            = client.Address2,
                City    = client.City,
                Phone   = client.Phone,
                ZipCode = client.ZipCode,
                EmergencyContactName  = client.EmergencyContactName,
                EmergencyContactPhone = client.EmergencyContactPhone,
                EthnicityId           = client.EthnicityId,
                ClientNumber          = client.ClientNumber,
                CountyOfResidenceId   = client.CountyOfResidenceId,
                CountyOfIncidentId    = client.CountyOfIncidentId,
                StateId  = client.StateId,
                GenderId = client.GenderId
            };

            var ethnicityName = EthnicityManager.GetById(client.EthnicityId);

            model.EthnicityName = ethnicityName.EthnicityName;

            var clientDemographics = DemographicManager.GetForClient(id);
            var checkBoxListItems  = new List <CheckBoxListItem>();

            foreach (var demographic in clientDemographics)
            {
                checkBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = demographic.DemographicId,
                    Display   = demographic.DemographicName,
                    IsChecked = clientDemographics.Where(x => x.DemographicId == demographic.DemographicId).Any()
                });
            }
            ;

            model.Demographics = checkBoxListItems;

            var clientAbuseType            = AbuseTypeManager.GetForClient(id);
            var abuseTypeCheckBoxListItems = new List <CheckBoxListItem>();

            foreach (var abuseType in clientAbuseType)
            {
                abuseTypeCheckBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = abuseType.AbuseTypeId,
                    Display   = abuseType.AbuseTypeName,
                    IsChecked = clientAbuseType.Where(x => x.AbuseTypeId == abuseType.AbuseTypeId).Any()
                });
            }
            ;

            model.AbuseTypes = abuseTypeCheckBoxListItems;

            return(View(model));
        }