//[Authorize(Roles = "ViewRole")] public IEnumerable <ApplicationRoleViewModel> Get() { try { //var pagination = Request.Headers["Pagination"]; //if (!string.IsNullOrEmpty(pagination)) //{ // string[] vals = pagination.ToString().Split(','); // int.TryParse(vals[0], out _page); // int.TryParse(vals[1], out _pageSize); //} var result = _appRoleService.GetAll(); //int currentPage = _page; //int currentPageSize = _pageSize; //var totalRecord = result.Count(); //var totalPages = (int)Math.Ceiling((double)totalRecord / _pageSize); //var resultPage = result.Skip((currentPage - 1) * currentPageSize).Take(currentPageSize); //Response.AddPagination(_page, _pageSize, totalRecord, totalPages); // IEnumerable<ListdomainObject> listPagedDomain = Mapper.Map<IEnumerable<ListdomainObject>, IEnumerable<ListdomainObject>>(domains); var model = ViewModelMapper <ApplicationRoleViewModel, IdentityRole> .MapObjects(result.ToList(), null); return(model); } catch (Exception ex) { return(new List <ApplicationRoleViewModel>()); } }
public IEnumerable <ApplicationUserViewModel> Get() { //var pagination = Request.Headers["Pagination"]; //if (!string.IsNullOrEmpty(pagination)) //{ // string[] vals = pagination.ToString().Split(','); // int.TryParse(vals[0], out _page); // int.TryParse(vals[1], out _pageSize); //} var userRoot = _userManager.GetUserId(User); var result = _userManager.Users.ToList().FindAll(x => x.LockoutEnabled && x.PARENT_ID == userRoot); // var s = result.FindAll(x => x.LockoutEnabled); //if (!String.IsNullOrEmpty(searchString)) //{ // result = result.Where(user => user.Email.Contains(searchString.ToLower()) || // user.FULLNAME.ToLower().Contains(searchString.ToLower())|| // user.PHONE.ToString().Contains(searchString)|| // user.UserName.ToLower().Contains(searchString.ToLower())).ToList(); //} //int currentPage = _page; //int currentPageSize = _pageSize; //var totalRecord = result.Count(); //var totalPages = (int)Math.Ceiling((double)totalRecord / _pageSize); //var users = result.Skip((currentPage - 1) * currentPageSize).Take(currentPageSize); //Response.AddPagination(_page, _pageSize, totalRecord, totalPages); var model = ViewModelMapper <ApplicationUserViewModel, ApplicationUser> .MapObjects(result.ToList(), null); return(model); }
//[Authorize(Roles = "ViewUserGroup")] public IEnumerable <ApplicationRoleViewModel> Details(int id) { ApplicationGroup appGroup = _appGroupService.GetDetail(id); if (appGroup == null) { return(null); } // var appGroupViewModel = ViewModelMapper<ApplicationGroupViewModel, ApplicationGroup>(appGroup); var appGroupViewModel = PropertyCopy.Copy <ApplicationGroupViewModel, ApplicationGroup> (appGroup); var listRoleByGroup = _appRoleService.GetListRoleByGroupId(appGroupViewModel.ID).ToList(); var listRoleByGroupViewModel = ViewModelMapper <ApplicationRoleViewModel, IdentityRole> .MapObjects(listRoleByGroup, null); var listRole = _appRoleService.GetAll().ToList(); var listRoleViewModel = ViewModelMapper <ApplicationRoleViewModel, IdentityRole> .MapObjects(listRole, null); foreach (var roleViewModel in listRoleViewModel) { foreach (var roleByGroupViewModel in listRoleByGroupViewModel) { if (roleByGroupViewModel.Id.Equals(roleViewModel.Id)) { roleViewModel.Check = true; break; } } } return(listRoleViewModel); }
public IEnumerable <ApplicationRoleViewModel> Get(string searchstring = null) { var result = _appRoleService.GetAll(); if (!String.IsNullOrEmpty(searchstring)) { result = result.Where(role => role.Name.ToLower().Contains(searchstring.ToLower())); } var model = ViewModelMapper <ApplicationRoleViewModel, IdentityRole> .MapObjects(result.ToList(), null); return(model.ToList()); }
public IEnumerable <ApplicationUserViewModel> Get(string searchstring = null) { var result = _userManager.Users; if (!String.IsNullOrEmpty(searchstring)) { result = result.Where(user => user.FULLNAME.ToLower().Contains(searchstring.ToLower()) || user.Email.ToLower().Contains(searchstring.ToLower()) || user.UserName.ToLower().Contains(searchstring.ToLower()) || user.PHONE.ToString().Contains(searchstring.ToLower())); } var model = ViewModelMapper <ApplicationUserViewModel, ApplicationUser> .MapObjects(result.ToList(), null); return(model.ToList()); }
public IEnumerable <ApplicationGroupViewModel> Details(string id) { ; if (string.IsNullOrEmpty(id.ToString())) { return(null); } var user = _userManager.FindByIdAsync(id.ToString()); if (user == null) { return(null); } else { var applicationUserViewModel = PropertyCopy.Copy <ApplicationUserViewModel, ApplicationUser>(user.Result); var listGroup = _appGroupService.GetListGroupByUserId(applicationUserViewModel.Id); var listGroupsViewModel = ViewModelMapper <ApplicationGroupViewModel, ApplicationGroup> .MapObjects(listGroup.ToList(), null); var result = _appGroupService.GetAll().ToList(); var model = Mapper.Map <IEnumerable <ApplicationGroup>, IEnumerable <ApplicationGroupViewModel> >(result).ToList(); foreach (var groupsByUserViewModel in listGroupsViewModel) { foreach (var group in model) { if (groupsByUserViewModel.ID.Equals(group.ID)) { group.Check = true; break; } } } // applicationUserViewModel.Groups = Mapper.Map<IEnumerable<ApplicationGroup>, IEnumerable<ApplicationGroupViewModel>>(listGroup); return(model); } }
public List <SellerViewModel> GetTopBonuSellerViewModels() { return(ViewModelMapper <SellerViewModel, ApplicationUser> .MapObjects(_userRepository.GetMulti(x => x.Bonus != 0).OrderByDescending(x => x.Bonus).Take(10).ToList())); }
public List <LastestTopicViewModel> GetLastestTopics() { return(ViewModelMapper <LastestTopicViewModel, Topic> .MapObjects(_topicRepository.GetAll().OrderByDescending(x => x.CreatedDate).Take(4).ToList(), _userRepository)); }
public List <ViewModel.Home.TopicViewModel> GetTop10Topics() { return(ViewModelMapper <TopicViewModel, Topic> .MapObjects(_topicRepository.GetAll().OrderByDescending(x => x.NoOfLikes).Take(10).ToList(), _userRepository)); }