public List <VMActivityLog> GetActivityLogs(PageModel pageModel) { var data = (from activity in _context.ActivityLogs join user in _context.UserMasters on activity.ActivityBy equals user.UserId join role in _context.RoleMasters on user.Role equals role.RoleId //where activity.ActivityBy > 0 select new { ActivityOn = activity.ActivityOn, ActivityByName = activity.ActivityBy, ActivityLogId = activity.ActivityLogId, ActivityTime = activity.ActivityTime, ActivityType = activity.ActivityType, ActivityFor = activity.ActivityFor }).ToList(); int totalRecords = data.Count; var data2 = (from d in data select new VMActivityLog { ActivityOn = (d.ActivityFor == "Role") ? _context.RoleMasters .Where(x => x.RoleId == d.ActivityOn) .Select(x => x.RoleName).FirstOrDefault() : _context.UserMasters .Where(x => x.UserId == d.ActivityOn) .Select(x => x.UserName).FirstOrDefault(), ActivityByName = _context.UserMasters.Where(x => x.UserId == d.ActivityByName) .Select(x => x.UserName).FirstOrDefault(), ActivityLogId = d.ActivityLogId, ActivityTime = d.ActivityTime, ActivityType = d.ActivityType, ActivityFor = d.ActivityFor, TotalRecords = totalRecords }).ToList(); if (pageModel.SortOrder == "desc") { data2 = PagingUtils.OrderDesc <VMActivityLog>(data2.AsQueryable <VMActivityLog>(), pageModel).ToList(); } else { data2 = PagingUtils.OrderAsc <VMActivityLog>(data2.AsQueryable <VMActivityLog>(), pageModel).ToList(); } return(data2); }
public List <VMRoleMaster> GetRoles(PageModel pageModel) { List <VMRoleMaster> data = new List <VMRoleMaster>(); var data2 = _context.RoleMasters.ToList(); int totalRecords = data.Count; data = (from d in data2 select new VMRoleMaster { RoleId = d.RoleId, RoleName = d.RoleName, TotalRecords = totalRecords }).ToList(); if (pageModel.SortOrder == "desc") { data = PagingUtils.OrderDesc <VMRoleMaster>(data.AsQueryable <VMRoleMaster>(), pageModel).ToList(); } else { data = PagingUtils.OrderAsc <VMRoleMaster>(data.AsQueryable <VMRoleMaster>(), pageModel).ToList(); } return(data); }