public ActionResult Index() { var activityLogSearchModel = new ActivityLogSearchModel(); // add all type of activities activityLogSearchModel.ActivityLogType.Add(new SelectListItem() { Value = Guid.Empty.ToString(), Text = "All" }); activityService.GetAllActivityTypes() .OrderBy(at => at.Name) .Select(at => { return new SelectListItem() { Value = at.RowId.ToString(), Text = at.Name }; }) .ForEach (item => { activityLogSearchModel.ActivityLogType.Add(item); }); activityLogSearchModel.Users.Add(new SelectListItem() { Value = Guid.Empty.ToString(), Text= localizationService.GetResource("Common.All") }); activityLogSearchModel.Users.AddRange( this.PrepareSelectList(userService, cacheManager, Guid.Empty, PublishingStatus.All)); return View(activityLogSearchModel); }
public ActionResult List(ActivityLogSearchModel model) { if (!Request.IsAjaxRequest()) return RedirectToAction(SystemRouteNames.Index); DateTime? startDateValue = (model.CreatedOnFrom == null) ? null : (DateTime?)dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, dateTimeHelper.CurrentTimeZone); DateTime? endDateValue = (model.CreatedOnTo == null) ? null : (DateTime?)dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, dateTimeHelper.CurrentTimeZone).AddDays(1); string cacheKey = ModelCacheEventUser.AUDITHISTORY_MODEL_KEY.FormatWith( "List.{0}.{1}.{2}.{3}".FormatWith((startDateValue.HasValue ? startDateValue.ToString() : string.Empty), (endDateValue.HasValue ? endDateValue.ToString() : string.Empty), model.ActivityLogTypeId.ToString(), model.UserId.ToString())); var cacheModel = cacheManager.Get(cacheKey, () => { var activityLogs = activityService.GetAllActivities(model.CreatedOnFrom, model.CreatedOnTo, model.UserId, model.ActivityLogTypeId) .Select(ah => { var activitylogModel = ah.ToModel(); activitylogModel.CreatedOn = ah.CreatedOn.ToString(StateKeyManager.DateTimeFormat); return activitylogModel; }); return activityLogs; }); return Json(new DataTablesParser<ActivityLogModel>(Request, cacheModel ).Parse()); }