public ActionResult BellNotifications() { var notification = new NotificationModel(); notification.Users = _userService.GetUnApprovedUsers().Select(x => new UserModel() { Id = x.Id, Username = x.UserName, CreatedOn = x.CreatedOn }).ToList(); notification.SystemLogs = _systemLogService.GetAllSystemLogs(fromUtc: DateTime.UtcNow, toUtc: DateTime.UtcNow).Select(s => new SystemLogModel() { Date = s.CreatedOn.Value.Date, EntityId = s.EntityId, Id = s.Id, EntityTypeName = s.EntityTypeName, IpAddress = s.IpAddress, Message = s.Message }).OrderByDescending(s => s.Date).Take(5).ToList(); notification.AuditRequests = _auditService.GetAllAuditsByDate(DateTime.UtcNow).Take(3).Select(a => new AuditModel() { AuditLogId = a.AuditLogId, EventDateUTC = a.EventDateUTC, EventType = a.EventType, LogDetails = a.LogDetails.Select(l => new TrackerEnabledDbContext.Common.Models.AuditLogDetail() { AuditLogId = l.AuditLogId, Id = l.Id, Log = l.Log, NewValue = l.NewValue, OriginalValue = l.OriginalValue, PropertyName = l.PropertyName }).ToList(), UserName = a.UserName }).ToList(); notification.NotificationCount = notification.Users.Count + notification.SystemLogs.Count + notification.AuditRequests.Count; return(View("~/Areas/Admin/Views/Common/BellNotifications.cshtml", notification)); }
public ActionResult LoadGrid() { try { var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var length = Request.Form.GetValues("length").FirstOrDefault(); var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]")?.FirstOrDefault() + "][name]")?.FirstOrDefault(); var sortColumnDir = Request.Form.GetValues("order[0][dir]")?.FirstOrDefault(); var searchValue = Request.Form.GetValues("search[value]")?.FirstOrDefault(); //Paging Size (10,20,50,100) int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; // Getting all data var logData = (from templogs in _systemLogService.GetAllSystemLogs() select templogs); //Search if (!string.IsNullOrEmpty(searchValue)) { logData = logData.Where(m => m.EntityTypeName.Contains(searchValue) || m.Message.Contains(searchValue) || m.StackTrace.Contains(searchValue)); } //total number of rows count var lstLogs = logData as SystemLog[] ?? logData.ToArray(); recordsTotal = lstLogs.Count(); //Paging var data = lstLogs.Skip(skip).Take(pageSize); //Returning Json Data return(new JsonResult() { Data = new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data.Select(eve => new SystemLogModel { Id = eve.Id, EntityId = eve.EntityId, EntityType = eve.EntityType, EntityTypeName = eve.EntityTypeName, ErrorId = eve.ErrorId, IpAddress = eve.IpAddress, IsException = eve.IsException, IsFixed = eve.IsFixed, Level = eve.Level, LogLevel = eve.LogLevel, Message = eve.Message, StackTrace = eve.StackTrace, Url = eve.Url, Date = eve.CreatedOn.Value, LogDateString = eve.CreatedOn.Value.ToString("U") }).OrderByDescending(x => x.CreatedOn).ToList() }, ContentEncoding = Encoding.Default, ContentType = "application/json", JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = int.MaxValue }); } catch (Exception ex) { throw new Exception(ex.Message); } }