Example #1
0
        public ActionResult AuthedNavMenu(Guid altId)
        {
            Contracts.DataModels.User user = AutoMapper.Mapper.Map <Contracts.DataModels.User>(_userRepository.GetByAltId(altId));
            var features     = _featureRepository.GetAll(null);
            var roleFeatures = _roleFeatureMappingRepository.GetByRoleId((int)user.RoleId);

            return(PartialView("PartialViews/_AuthedNavMenu", new MenuResponseViewModel {
                Features = AutoMapper.Mapper.Map <List <Contracts.Models.Feature> >(features.Where(w => roleFeatures.Select(s => s.FeatureId).Contains(w.Id))),
                User = AutoMapper.Mapper.Map <Contracts.Models.User>(user)
            }));
        }
        public AuthedRoleFeatureQueryResult Handle(AuthedRoleFeatureQuery query)
        {
            List <User> users = new List <User>();

            try
            {
                var user      = _userRepository.GetByAltId(query.UserAltId);
                var featureId = _roleFeatureMappingRepository.GetByRoleId(user.RolesId).Select(s => s.FeatureId).Distinct();
                IEnumerable <FIL.Contracts.DataModels.Feature> featureList = _featureRepository.GetByIds(featureId);
                return(new AuthedRoleFeatureQueryResult
                {
                    Feature = AutoMapper.Mapper.Map <IEnumerable <FIL.Contracts.Models.Feature> >(featureList)
                });
            }
            catch (System.Exception ex)
            {
                return(new AuthedRoleFeatureQueryResult {
                });
            }
        }