public UnitOfWork() { _db = new URFXDbContext(); }
public ResponseMessage RolesPaging(PagingModel model) { ResponseMessage responseMessage = new ResponseMessage(); string searchparam = model.SearchText == null ? "" : model.SearchText; List<RoleBindingModel> roles; URFXDbContext db = new URFXDbContext(); if (searchparam == "") { roles = db.Roles.Select(x => new RoleBindingModel() { Id = x.Id, Name = x.Name }).ToList(); } else { roles = db.Roles.Select(x => new RoleBindingModel() { Id = x.Id, Name = x.Name }).Where(y => y.Name.ToLower().Contains(searchparam.ToLower())).ToList(); } responseMessage.totalRecords = roles.Count(); roles = roles.OrderBy(x => x.Name).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList(); responseMessage.data = roles; return responseMessage; }
public IHttpActionResult GetAllRole() { URFXDbContext db = new URFXDbContext(); var roles = db.Roles.Select(x => new RoleBindingModel() { Id = x.Id, Name = x.Name }).ToList(); return Ok(roles); }
public ResponseMessage Paging(PagingModel model) { ResponseMessage responseMessage = new ResponseMessage(); var context = new URFXDbContext(); var role = context.Roles.Where(x => x.Name == URFXRoles.Admin.ToString()).SingleOrDefault(); string searchparam = model.SearchText == null ? "" : model.SearchText; List<ApplicationUser> users = UserManager.Users.Where(x => (x.Roles.Where(r => r.RoleId != role.Id).Count() > 0)).ToList(); users.ForEach(x => { var roles = UserManager.GetRoles(x.Id); var userRole = roles.FirstOrDefault(); x.Role = userRole; }); if (searchparam != "") { users = users.Where(x => x.Email.ToLower().Contains(searchparam.ToLower())).ToList(); } responseMessage.totalRecords = users.Count(); users = users.OrderBy(x => x.UserName).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList(); responseMessage.data = users; return responseMessage; }
public IQueryable GetAllUser() { var context = new URFXDbContext(); var role = context.Roles.Where(x => x.Name == URFXRoles.Admin.ToString()).SingleOrDefault(); IQueryable users = UserManager.Users.Where(x => (x.Roles.Where(r => r.RoleId != role.Id).Count() > 0)); return users; }