Esempio n. 1
0
        public ActionResult DelGridDomains(ProfileMembers pm, int domainDeleteId)
        {
            if (ModelState.IsValid)
            {
                List <int> groups = new List <int>();

                foreach (var domain in pm.Profile.GroupingMetadatas)
                {
                    if (domain.GroupId != domainDeleteId)
                    {
                        groups.Add(domain.GroupId);
                    }
                }

                _writer.UpdateProfileDetailsGroupIds(pm.Profile.Id, groups);
                _writer.DeleteGroupingMetadata(domainDeleteId);
            }

            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }

            return(View("ProfilesAndIndicators"));
        }
        public ActionResult SaveGridDomains(ProfileMembers pm, string newDomain)
        {
            if (ModelState.IsValid)
            {
                string allGroupIds = null;
                // Update the posted-back data
                foreach (var domain in pm.Profile.GroupingMetadatas)
                {
                    allGroupIds += domain.GroupId + ",";
                    _writer.UpdateGroupingMetadata(domain);
                }

                // Insert any newly added domains
                if (!String.IsNullOrEmpty(newDomain))
                {
                    var nextSequenceNumber = pm.Profile.GroupingMetadatas.Last().Sequence + 1;
                    _writer.NewGroupingMetadata(newDomain, nextSequenceNumber, pm.Profile.Id);
                }
            }

            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }

            return(View("ProfilesAndIndicators"));
        }
Esempio n. 3
0
        /// <summary>
        /// Map a member to relate its serialization/deserialization behaviors.
        /// </summary>
        /// <param name="memberExpression"></param>
        public ProfileMember <TMember> Map <TMember>(Expression <Func <TProfile, TMember> > expression)
        {
            MemberExpression        memberExpression = ExpressionHelper.GetMemberExpression(expression.Body);
            Type                    genericType      = typeof(ProfileMember <>).MakeGenericType(typeof(TMember));
            ProfileMember <TMember> member           = Activator.CreateInstance(genericType, memberExpression) as ProfileMember <TMember>;

            ProfileMembers.Add(member);
            return(member);
        }
        private IList <GroupingMetadata> ReloadGridDomains(string selectedProfile, ProfileRepository profileRepository)
        {
            var model = new ProfileMembers
            {
                UrlKey  = selectedProfile,
                Profile = CommonUtilities.GetProfile(selectedProfile, 1, -1, profileRepository)
            };

            return(model.Profile.GroupingMetadatas);
        }
        public int GetSelectedGroupIdUsingProfileKeyDomainAndAreaTypeId(string selectedProfile, int domainNumber, int areaTypeId)
        {
            var model = new ProfileMembers
            {
                UrlKey  = selectedProfile,
                Profile = CommonUtilities.GetProfile(selectedProfile, domainNumber, areaTypeId, _profileRepository)
            };

            IList <GroupingMetadata> groupingMetadatas = model.Profile.GroupingMetadatas;

            return(groupingMetadatas.FirstOrDefault(x => x.Sequence == domainNumber).GroupId);
        }
Esempio n. 6
0
        private void LoadProfileAndDomainDropdowns()
        {
            List <SelectListItem> listOfProfiles =
                CommonUtilities.GetOrderedListOfProfilesForCurrentUser(new BaseDataModel())
                .ToList();

            ViewBag.listOfProfiles = listOfProfiles;

            var domains        = new ProfileMembers();
            var defaultProfile = listOfProfiles.FirstOrDefault();

            ViewBag.ListOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);
        }
        public JsonResult ReloadDomains(string selectedProfile)
        {
            var model = new ProfileMembers
                {
                    UrlKey = selectedProfile,
                    Profile = CommonUtilities.GetProfile(selectedProfile, 1, AreaTypeIds.CountyAndUnitaryAuthority, _profileRepository)
                };

            IList<GroupingMetadata> groupingMetadatas = model.Profile.GroupingMetadatas;

            var domains = new SelectList(groupingMetadatas.OrderBy(g => g.Sequence), "GroupId", "GroupName");
            return Json(domains);
        }
        public JsonResult ReloadDomains(string selectedProfile)
        {
            var model = new ProfileMembers
            {
                UrlKey  = selectedProfile,
                Profile = CommonUtilities.GetProfile(selectedProfile, 1, AreaTypeIds.CountyAndUnitaryAuthority, _profileRepository)
            };

            IList <GroupingMetadata> groupingMetadatas = model.Profile.GroupingMetadatas;

            var domains = new SelectList(groupingMetadatas.OrderBy(g => g.Sequence), "GroupId", "GroupName");

            return(Json(domains));
        }
        public ActionResult ReorderIndicators(int selectedDomain, string urlKey, int selectedGroupId, int selectedAreaType)
        {
            var model = new ProfileMembers
            {
                UrlKey  = urlKey,
                Profile = GetProfile(urlKey, selectedDomain, selectedAreaType)
            };

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ReorderIndicators", model));
            }

            return(View("ProfilesAndIndicators"));
        }
        public ActionResult IndicatorNew()
        {
            // Get text properties of selected indicator
            var properties = _reader.GetIndicatorMetadataTextProperties();

            var userId        = _reader.GetUserByUserName(UserDetails.CurrentUser().Name).Id;
            var permissionIds = _reader.GetUserGroupPermissionsByUserId(userId).Select(x => x.ProfileId);
            var model         = new ProfileIndex {
                Profiles =
                    _reader.GetProfiles()
                    .OrderBy(x => x.Name)
                    .Where(x => permissionIds.Contains(x.Id))
            };

            var listOfProfiles = CommonUtilities.GetOrderedListOfProfiles(model.Profiles);

            ViewBag.listOfProfiles = listOfProfiles;

            var domains        = new ProfileMembers();
            var defaultProfile = listOfProfiles.FirstOrDefault();

            ViewBag.listOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);

            ViewBag.selectedSex = new SelectList(_lookUpsRepository.GetSexes(), "SexID", "Description");

            ViewBag.selectedAge = new SelectList(_lookUpsRepository.GetAges(), "AgeID", "Description");

            var comparatorOptions = CommonUtilities.GetListOfComparators(ComparatorIds.NationalAndSubnational);

            ViewBag.selectedComparator = new SelectList(comparatorOptions, "Value", "Text");

            ViewBag.selectedComparatorMethod = new SelectList(_reader.GetAllComparatorMethods(), "Id", "Name");

            ViewBag.selectedYearType = new SelectList(_lookUpsRepository.GetYearTypes(), "Id", "Label");

            ViewBag.selectedValueType = new SelectList(_lookUpsRepository.GetIndicatorValueTypes(), "Id", "Label");

            ViewBag.selectedCIMethodType = new SelectList(_lookUpsRepository.GetConfidenceIntervalMethods(), "Id", "Name");

            ViewBag.selectedUnitType = new SelectList(_lookUpsRepository.GetUnits(), "Id", "Label");

            ViewBag.selectedDenominatorType = new SelectList(_lookUpsRepository.GetDenominatorTypes(), "Id", "Name");

            return(View(properties));
        }
        public ActionResult MoveIndicators(IEnumerable <string> jdata, string selectedProfileUrlkey, string selectedProfileName,
                                           int selectedDomainId, string selectedDomainName, int selectedAreaTypeId)
        {
            var model = new MoveIndicatorsModel
            {
                UrlKey      = selectedProfileUrlkey,
                Profile     = GetProfile(selectedProfileUrlkey, selectedDomainId, selectedAreaTypeId),
                DomainName  = selectedDomainName,
                DomainId    = selectedDomainId,
                ProfileName = selectedProfileName,
                AreaTypeId  = selectedAreaTypeId,
                IndicatorsThatCantBeTransferred = null,
            };

            var listOfProfiles = GetOrderedListOfProfilesForCurrentUser(model);

            var domains        = new ProfileMembers();
            var defaultProfile = listOfProfiles.FirstOrDefault(x => x.Selected) ?? listOfProfiles.FirstOrDefault();

            defaultProfile.Selected = true;

            model.ListOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);

            var userPermissions = CommonUtilities.GetUserGroupPermissionsByUserId(_reader.GetUserByUserName(_userName).Id);

            model.UserGroupPermissions = userPermissions.FirstOrDefault(x => x.ProfileId == _reader.GetProfileDetails(model.UrlKey).Id);

            var indicatorSpecifiers = IndicatorSpecifierParser.Parse(jdata.ToArray());

            model.IndicatorsToTransfer = GetSpecifiedIndicatorNames(indicatorSpecifiers,
                                                                    model.Profile.IndicatorNames);

            ViewBag.SexList = _lookUpsRepository.GetSexes();

            ViewBag.AgeList = _lookUpsRepository.GetAges();


            if (Request.IsAjaxRequest())
            {
                return(PartialView("_MoveSelectedIndicators", model));
            }

            return(View("ProfilesAndIndicators"));
        }
        public ActionResult IndicatorNew()
        {
            // Get text properties of selected indicator
            var properties = _reader.GetIndicatorMetadataTextProperties();

            var userId = _reader.GetUserByUserName(UserDetails.CurrentUser().Name).Id;
            var permissionIds = _reader.GetUserGroupPermissionsByUserId(userId).Select(x => x.ProfileId);
            var model = new ProfileIndex { Profiles = 
                _reader.GetProfiles()
                .OrderBy(x => x.Name)
                .Where(x => permissionIds.Contains(x.Id)) };

            var listOfProfiles = CommonUtilities.GetOrderedListOfProfiles(model.Profiles);
            ViewBag.listOfProfiles = listOfProfiles;

            var domains = new ProfileMembers();
            var defaultProfile = listOfProfiles.FirstOrDefault();
            
            ViewBag.listOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile,_profileRepository);

            ViewBag.selectedSex = new SelectList(_lookUpsRepository.GetSexes(), "SexID", "Description");

            ViewBag.selectedAge = new SelectList(_lookUpsRepository.GetAges(), "AgeID", "Description");

            var comparatorOptions = CommonUtilities.GetListOfComparators(ComparatorIds.NationalAndSubnational);
            ViewBag.selectedComparator = new SelectList(comparatorOptions, "Value", "Text");

            ViewBag.selectedComparatorMethod = new SelectList(_reader.GetAllComparatorMethods(), "Id", "Name");

            ViewBag.selectedYearType = new SelectList(_lookUpsRepository.GetYearTypes(), "Id", "Label");

            ViewBag.selectedValueType = new SelectList(_lookUpsRepository.GetIndicatorValueTypes(), "Id", "Label");

            ViewBag.selectedCIMethodType = new SelectList(_lookUpsRepository.GetConfidenceIntervalMethods(), "Id", "Name");

            ViewBag.selectedUnitType = new SelectList(_lookUpsRepository.GetUnits(), "Id", "Label");

            ViewBag.selectedDenominatorType = new SelectList(_lookUpsRepository.GetDenominatorTypes(), "Id", "Name");
            
            return View(properties);
        }
        public ActionResult DeleteDomain(ProfileMembers pm, int domainDeleteId)
        {
            var profileId = -1;

            if (ModelState.IsValid)
            {
                List <int> groupIds = new List <int>();

                var profile = pm.Profile;
                profileId = profile.Id;
                foreach (var domain in profile.GroupingMetadatas)
                {
                    if (domain.GroupId != domainDeleteId)
                    {
                        groupIds.Add(domain.GroupId);
                    }
                }

                _writer.DeleteGroupingMetadata(domainDeleteId);
                _writer.ReorderDomainSequence(groupIds);
            }

            return(Index(profileId));
        }
        public ActionResult IndicatorEdit(string urlKey, int areaType, int selectedDomainNumber, int indicatorId, int ageId, int sexId)
        {
            Profile profile = GetProfile(urlKey, selectedDomainNumber, areaType);

            // Get text properties of selected indicator
            IList<IndicatorMetadataTextProperty> properties = _reader.GetIndicatorMetadataTextProperties();
            int groupId = profile.GetSelectedGroupingMetadata(selectedDomainNumber).GroupId;

            // Assemble model
            var model = new IndicatorEdit
            {
                SelectedIndicatorId = indicatorId,
                UrlKey = urlKey,
                Profile = profile,
                TextValues = _reader.GetIndicatorTextValues(indicatorId, properties, profile.Id).ToList()
            };

            // Prev/Next
            if (profile.IndicatorNames.Count > 0)
            {
                int index = -1;
                IList<GroupingPlusName> names = profile.IndicatorNames;
                for (int i = 0; i < names.Count(); i++)
                {
                    if (names[i].IndicatorId == indicatorId)
                    {
                        index = i;
                        break;
                    }
                }

                int prevIndex = index > 0 ? index - 1 : names.Count - 1;
                int nextIndex = index == names.Count - 1 ? 0 : index + 1;
                model.IndicatorIdNext = names[nextIndex].IndicatorId;
                model.IndicatorIdPrevious = names[prevIndex].IndicatorId;
            }

            //Get the indicatore meta data
            IndicatorMetadata indicatorMetaData = _reader.GetIndicatorMetadata(indicatorId);
            model.IndicatorMetadata = indicatorMetaData;

            IList<Grouping> groupList = _reader.GetGroupings(groupId);
            IEnumerable<Grouping> indicatorGroupData =
                groupList.Where(
                    g =>
                        g.IndicatorId == indicatorId &&
                        g.GroupId == groupId &&
                        g.AreaTypeId == areaType &&
                        g.AgeId == ageId &&
                        g.SexId == sexId);
            Grouping[] groupData = indicatorGroupData as Grouping[] ?? indicatorGroupData.ToArray();
            model.Grouping = groupData.FirstOrDefault();

            //Set the comparator Id if this is a multiple comparator grouping record
            if (groupData.Count() > 1)
            {
                //There are multiple comparator indicators
                if (model.Grouping != null)
                {
                    model.Grouping.ComparatorId = ComparatorIds.NationalAndSubnational;
                }
            }

            model.urlKey = urlKey;

            var listOfProfiles = CommonUtilities.GetOrderedListOfProfilesForCurrentUser(urlKey);

            ViewBag.listOfProfiles = listOfProfiles;

            var domains = new ProfileMembers();

            var defaultProfile = listOfProfiles.FirstOrDefault(x => x.Selected) ?? listOfProfiles.FirstOrDefault();
            defaultProfile.Selected = true;

            ViewBag.listOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);

            IEnumerable<UserGroupPermissions> userPermissions =
                CommonUtilities.GetUserGroupPermissionsByUserId(_reader.GetUserByUserName(_userName).Id);
            model.UserGroupPermissions =
                userPermissions.FirstOrDefault(x => x.ProfileId == _reader.GetProfileDetails(model.UrlKey).Id);

            if (HttpContext.Request.UrlReferrer != null) model.ReturnUrl = HttpContext.Request.UrlReferrer.ToString();

            ViewBag.SexId = new SelectList(_lookUpsRepository.GetSexes(), "SexID", "Description");

            ViewBag.AgeId = new SelectList(_lookUpsRepository.GetAges(), "AgeID", "Description");

            ViewBag.YearTypeId = new SelectList(_lookUpsRepository.GetYearTypes(), "Id", "Label");

            ViewBag.ValueTypeId = new SelectList(_lookUpsRepository.GetIndicatorValueTypes(), "Id", "Label");

            ViewBag.CIMethodId = new SelectList(_lookUpsRepository.GetConfidenceIntervalMethods(), "Id", "Name");

            var unitList = new SelectList(_lookUpsRepository.GetUnits(), "Id", "Label");
            ViewBag.UnitId = unitList;

            ViewBag.DenominatorTypeId = new SelectList(_lookUpsRepository.GetDenominatorTypes(), "Id", "Name");

            return View("IndicatorEdit", model);
        }
        public ActionResult DeleteDomain(ProfileMembers pm, int domainDeleteId)
        {
            var profileId = -1;

            if (ModelState.IsValid)
            {
                List<int> groupIds = new List<int>();

                var profile = pm.Profile;
                profileId = profile.Id;
                foreach (var domain in profile.GroupingMetadatas)
                {
                    if (domain.GroupId != domainDeleteId)
                    {
                        groupIds.Add(domain.GroupId);
                    }
                }

                _writer.DeleteGroupingMetadata(domainDeleteId);
                _writer.ReorderDomainSequence(groupIds);
            }

            return Index(profileId);
        }
        public ActionResult ReorderIndicators(int selectedDomain, string urlKey, int selectedGroupId, int selectedAreaType)
        {
            var model = new ProfileMembers
            {
                UrlKey = urlKey,
                Profile = GetProfile(urlKey, selectedDomain, selectedAreaType)
            };

            if (Request.IsAjaxRequest())
            {
                return PartialView("_ReorderIndicators", model);
            }

            return View("ProfilesAndIndicators");
        }
        private IList<GroupingMetadata> ReloadGridDomains(string selectedProfile, ProfileRepository profileRepository)
        {
            var model = new ProfileMembers
                {
                    UrlKey = selectedProfile,
                    Profile = CommonUtilities.GetProfile(selectedProfile, 1, -1, profileRepository)
                };

            return model.Profile.GroupingMetadatas;
        }
Esempio n. 18
0
        public ActionResult IndicatorEdit(string urlKey, int areaType, int selectedDomainNumber, int indicatorId, int ageId, int sexId)
        {
            Profile profile = GetProfile(urlKey, selectedDomainNumber, areaType);

            // Get text properties of selected indicator
            IList <IndicatorMetadataTextProperty> properties = _reader.GetIndicatorMetadataTextProperties();
            int groupId = profile.GetSelectedGroupingMetadata(selectedDomainNumber).GroupId;

            // Assemble model
            var model = new IndicatorEdit
            {
                SelectedIndicatorId = indicatorId,
                UrlKey     = urlKey,
                Profile    = profile,
                TextValues = _reader.GetIndicatorTextValues(indicatorId, properties, profile.Id).ToList()
            };

            // Prev/Next
            if (profile.IndicatorNames.Count > 0)
            {
                int index = -1;
                IList <GroupingPlusName> names = profile.IndicatorNames;
                for (int i = 0; i < names.Count(); i++)
                {
                    if (names[i].IndicatorId == indicatorId)
                    {
                        index = i;
                        break;
                    }
                }

                int prevIndex = index > 0 ? index - 1 : names.Count - 1;
                int nextIndex = index == names.Count - 1 ? 0 : index + 1;
                model.IndicatorIdNext     = names[nextIndex].IndicatorId;
                model.IndicatorIdPrevious = names[prevIndex].IndicatorId;
            }

            //Get the indicatore meta data
            IndicatorMetadata indicatorMetaData = _reader.GetIndicatorMetadata(indicatorId);

            model.IndicatorMetadata = indicatorMetaData;

            IList <Grouping>       groupList          = _reader.GetGroupings(groupId);
            IEnumerable <Grouping> indicatorGroupData =
                groupList.Where(
                    g =>
                    g.IndicatorId == indicatorId &&
                    g.GroupId == groupId &&
                    g.AreaTypeId == areaType &&
                    g.AgeId == ageId &&
                    g.SexId == sexId);

            Grouping[] groupData = indicatorGroupData as Grouping[] ?? indicatorGroupData.ToArray();
            model.Grouping = groupData.FirstOrDefault();

            //Set the comparator Id if this is a multiple comparator grouping record
            if (groupData.Count() > 1)
            {
                //There are multiple comparator indicators
                if (model.Grouping != null)
                {
                    model.Grouping.ComparatorId = ComparatorIds.NationalAndSubnational;
                }
            }

            model.urlKey = urlKey;

            var listOfProfiles = CommonUtilities.GetOrderedListOfProfilesForCurrentUser(urlKey);

            ViewBag.listOfProfiles = listOfProfiles;

            var domains = new ProfileMembers();

            var defaultProfile = listOfProfiles.FirstOrDefault(x => x.Selected) ?? listOfProfiles.FirstOrDefault();

            if (defaultProfile != null)
            {
                defaultProfile.Selected = true;
            }

            ViewBag.listOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);

            IEnumerable <UserGroupPermissions> userPermissions =
                CommonUtilities.GetUserGroupPermissionsByUserId(_reader.GetUserByUserName(_userName).Id);

            model.UserGroupPermissions =
                userPermissions.FirstOrDefault(x => x.ProfileId == _reader.GetProfileDetails(model.UrlKey).Id);

            if (HttpContext.Request.UrlReferrer != null)
            {
                model.ReturnUrl = HttpContext.Request.UrlReferrer.ToString();
            }

            ViewBag.SexId = new SelectList(_lookUpsRepository.GetSexes(), "SexID", "Description");

            ViewBag.AgeId = new SelectList(_lookUpsRepository.GetAges(), "AgeID", "Description");

            ViewBag.YearTypeId = new SelectList(_lookUpsRepository.GetYearTypes(), "Id", "Label");

            ViewBag.ValueTypeId = new SelectList(_lookUpsRepository.GetIndicatorValueTypes(), "Id", "Label");

            ViewBag.CIMethodId = new SelectList(_lookUpsRepository.GetConfidenceIntervalMethods(), "Id", "Name");

            var unitList = new SelectList(_lookUpsRepository.GetUnits(), "Id", "Label");

            ViewBag.UnitId = unitList;

            ViewBag.DenominatorTypeId = new SelectList(_lookUpsRepository.GetDenominatorTypes(), "Id", "Name");

            return(View("IndicatorEdit", model));
        }
        public ActionResult DelGridDomains(ProfileMembers pm, int domainDeleteId)
        {
            if (ModelState.IsValid) 
            { 
            List<int> groups = new List<int>();

            foreach (var domain in pm.Profile.GroupingMetadatas)
            {
                if (domain.GroupId != domainDeleteId)
                {
                     groups.Add(domain.GroupId);
                }
               
               
            }

            _writer.UpdateProfileDetailsGroupIds(pm.Profile.Id, groups);
            _writer.DeleteGroupingMetadata(domainDeleteId);

          
            }

            if (Request.UrlReferrer != null) return Redirect(Request.UrlReferrer.AbsoluteUri);

            return View("ProfilesAndIndicators");
        }
        public int GetSelectedGroupIdUsingProfileKeyDomainAndAreaTypeId(string selectedProfile, int domainNumber, int areaTypeId)
        {
            var model = new ProfileMembers
            {
                UrlKey = selectedProfile,
                Profile = CommonUtilities.GetProfile(selectedProfile, domainNumber, areaTypeId, _profileRepository)
            };

            IList<GroupingMetadata> groupingMetadatas = model.Profile.GroupingMetadatas;

            return groupingMetadatas.FirstOrDefault(x => x.Sequence == domainNumber).GroupId;
        }
        public ActionResult SaveGridDomains(ProfileMembers pm, string newDomain)
        {
            if (ModelState.IsValid)
            {
                string allGroupIds = null;
                //OK, now update the posted-back data...
                foreach (var domain in pm.Profile.GroupingMetadatas)
                {
                    allGroupIds += domain.GroupId + ",";
                    _writer.Update(domain);
                }

                //insert any newly added domains
                if (!String.IsNullOrEmpty(newDomain))
                {
                    var groupingMetadata = _writer.NewGroupingMetadata(newDomain,
                        pm.Profile.GroupingMetadatas.Last().Sequence + 1);

                    _dataAccess.UpdateProfileGroupIds(allGroupIds + groupingMetadata.GroupId.ToString(), pm.Profile.Id);
                }
            }

            if (Request.UrlReferrer != null) return Redirect(Request.UrlReferrer.AbsoluteUri);

            return View("ProfilesAndIndicators");
        }
        public ActionResult CopyIndicators(IEnumerable<string> jdata, string selectedProfileUrlkey, string selectedProfileName, int selectedDomainId, string selectedDomainName, int selectedAreaTypeId)
        {
            var model = new CopyIndicatorsModel
            {
                UrlKey = selectedProfileUrlkey,
                Profile = GetProfile(selectedProfileUrlkey, selectedDomainId, selectedAreaTypeId),
                DomainName = selectedDomainName,
                DomainId = selectedDomainId,
                ProfileName = selectedProfileName,
                AreaTypeId = selectedAreaTypeId,
                IndicatorsThatCantBeTransferred = null,
            };

            var listOfProfiles = GetOrderedListOfProfilesForCurrentUser(model);

            var domains = new ProfileMembers();
            var defaultProfile = listOfProfiles.FirstOrDefault(x => x.Selected) ?? listOfProfiles.FirstOrDefault();
            defaultProfile.Selected = true;

            model.ListOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);
            model.GroupId = Convert.ToInt32(model.ListOfDomains.FirstOrDefault(x => x.Selected).Value);

            var userPermissions = CommonUtilities.GetUserGroupPermissionsByUserId(_reader.GetUserByUserName(_userName).Id);
            model.UserGroupPermissions = userPermissions.FirstOrDefault(x => x.ProfileId == _reader.GetProfileDetails(model.UrlKey).Id);

            var indicatorSpecifiers = IndicatorSpecifierParser.Parse(jdata.ToArray());
            model.IndicatorsToTransfer = GetSpecifiedIndicatorNames(indicatorSpecifiers,
                model.Profile.IndicatorNames);

            ViewBag.SexList = _lookUpsRepository.GetSexes();

            ViewBag.AgeList = _lookUpsRepository.GetAges();

            if (Request.IsAjaxRequest())
            {
                return PartialView("_CopySelectedIndicators", model);
            }

            return View("ProfilesAndIndicators");
        }
        private void LoadProfileAndDomainDropdowns()
        {
            List<SelectListItem> listOfProfiles =
                CommonUtilities.GetOrderedListOfProfilesForCurrentUser(new BaseDataModel())
                .ToList();
            ViewBag.listOfProfiles = listOfProfiles;

            var domains = new ProfileMembers();
            var defaultProfile = listOfProfiles.FirstOrDefault();
            ViewBag.ListOfDomains = CommonUtilities.GetOrderedListOfDomainsWithGroupId(domains, defaultProfile, _profileRepository);
        }
        public ActionResult SaveGridDomains(ProfileMembers pm, string newDomain)
        {
            if (ModelState.IsValid)
            {
                string allGroupIds = null;
                // Update the posted-back data
                foreach (var domain in pm.Profile.GroupingMetadatas)
                {
                    allGroupIds += domain.GroupId + ",";
                    _writer.UpdateGroupingMetadata(domain);
                }

                // Insert any newly added domains
                if (!String.IsNullOrEmpty(newDomain))
                {
                    var nextSequenceNumber = pm.Profile.GroupingMetadatas.Last().Sequence + 1;
                    _writer.NewGroupingMetadata(newDomain, nextSequenceNumber, pm.Profile.Id);
                }
            }

            if (Request.UrlReferrer != null)
            {
                return Redirect(Request.UrlReferrer.AbsoluteUri);
            }

            return View("ProfilesAndIndicators");
        }
        public static IEnumerable<SelectListItem> GetOrderedListOfDomainsWithGroupId(ProfileMembers domains, SelectListItem defaultProfile, ProfileRepository profileRepository)
        {
            if (defaultProfile != null)
                domains.Profile = GetProfile(defaultProfile.Value, 0, -1, profileRepository);

            var listOfDomains = new SelectList(domains.Profile.GroupingMetadatas.OrderBy(g => g.Sequence), "GroupId", "GroupName");
            var selectedDomain = new SelectList(listOfDomains, "Value", "Key", listOfDomains.FirstOrDefault().Value).SelectedValue.ToString();
            return listOfDomains.Select(x => new SelectListItem { Selected = (x.Value == selectedDomain), Text = x.Text, Value = x.Value }); ;
        }