public async Task <AccessRightViewModel> Get(Guid featureId, Guid groupId) { var item = await this._unitOfWork.AccessRights.GetItem(featureId, groupId); var branch = new AccessRightViewModel { FeatureID = item.FeatureId, FeatureName = item.FeatureName, GroupID = item.GroupId, GroupName = item.GroupName, View = item.View, Edit = item.Edit, Create = item.Create, Delete = item.Delete }; return(branch); }
public ActionResult Create() { var model = new AccessRightViewModel { //AccessRightPageMenuViewModels = new List<AccessRightPageMenuViewModel>(), ListPages = _pageRepository.GetPages().ToList(), UserTypes = _userTypeRepository.GetUserTypes().ToList(), UserType_AccessRightPageViewModel = new List <UserType_AccessRightPageViewModel>() }; foreach (var userType in model.UserTypes) { var list = _pageRepository.GetPagesAccessRight(0, userType.Id).Select(item => item.Id).ToList(); if (list != null && list.Count > 0) { var userType_AccessRightPageViewModel = new UserType_AccessRightPageViewModel(); userType_AccessRightPageViewModel.UserTypeId = userType.Id; userType_AccessRightPageViewModel.ListAccessRightPage = list; model.UserType_AccessRightPageViewModel.Add(userType_AccessRightPageViewModel); } } return(View("Create", model)); }
public ActionResult Create(int?userTypeId, int?userId) { var model = new AccessRightViewModel(); //var listusertypes = _userTypeRepository.GetUserTypes().Where(item => item.Id != 1).OrderBy(item => item.Name).ToList(); //model.ListUserTypes = new List<UserTypeViewModel>(); //AutoMapper.Mapper.Map(listusertypes, model.ListUserTypes); //foreach (var item in model.ListUserTypes) //{ model.ListUserType = _userTypeRepository.GetUserTypes().Where(i => i.Code != "admin").ToList(); //} model.ListUser = _userRepository.GetAllvwUsers().Where(i => i.UserTypeCode != "admin").ToList(); model.UserTypeId = userTypeId; model.UserId = userId; if (model.UserTypeId != null) { if (model.UserId != null) { model.ListAccessRight = _pageRepository.GetPagesAccessRight(model.UserId.Value, model.UserTypeId.Value).Select(item => item.Id).ToList(); } else { model.ListAccessRight = _pageRepository.GetPagesUserTypeAccessRight(model.UserTypeId.Value).Select(item => item.Id).ToList(); } var list = _pageRepository.GetPages().Where(item => item.IsVisible.Value).ToList(); //var userType = _userTypeRepository.GetUserTypeById(Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId); model.ListPageGroup = list.Where(item => item.ParentActionId == null).GroupBy(item => item.GroupName) .Select(g1 => new PageGroupViewModel { Id = 0, Name = g1.Key, ListPageGroup = g1.GroupBy(item => item.ControllerDisplayName).Select(g2 => new PageGroupViewModel { Id = 0, Name = g2.Key, ListPageGroup = g2.Select(g3 => new PageGroupViewModel { Id = g3.Id, Name = g3.Name, Desc = g3.ActionName, Selected = model.ListAccessRight.Contains(g3.Id), Visible = g3.IsVisible == null ? false : g3.IsVisible.Value, ListSubAction = list.Where(x => x.ParentActionId == g3.Id).Select(x => new PageGroupViewModel { Id = x.Id, Name = x.Name, Desc = x.ActionName, Selected = model.ListAccessRight.Contains(x.Id), Visible = x.IsVisible == null ? false : x.IsVisible.Value }).OrderBy(item => item.Name).ToList() }).OrderBy(item => item.Name).ToList() }).OrderBy(item => item.Name).ToList() }) .OrderBy(item => item.Name) .ToList(); } return(View("Create", model)); }