public async Task <IActionResult> Index(int page = 1, string Name = null, DateTime?StartDate = null, DateTime?EndDate = null) { var model = new PermissionsGroupsViewModel { Name = Name , StartDate = StartDate.HasValue ? ConvertDatetime.ConvertToGregorianDate(StartDate.Value) : StartDate , EndDate = EndDate.HasValue ? ConvertDatetime.ConvertToGregorianDate(EndDate.Value) : EndDate }; var permissionGroups = await permissionsGroupService.Search(Name, StartDate, EndDate); //if (permissionGroups.Count > 0) //{ // var List = mapper.Map<List<PermissionsGroupsViewModel>>(permissionGroups); // model.PermissionsGroupsList = List.ToPagedList(page, Constants.PageSize); //} var List = mapper.Map <List <PermissionsGroupsViewModel> >(permissionGroups); model.PermissionsGroupsList = List.ToPagedList(page, Constants.PageSize); await model.FillLists(sessionService, adminsService); ViewBag.sessionService = sessionService; return(View(model)); }
public async Task <IActionResult> Index(int page = 1, DateTime?DateFrom = null, DateTime?DateTo = null, string RowId = "", LoggingAction?LoggingAction = null, LoggingCategory?LoggingCategory = null) { DateFrom = (DateFrom != null && DateFrom != DateTime.MinValue) ? ConvertDatetime.ConvertToGregorianDate((DateTime)DateFrom) : DateFrom; DateTo = (DateTo != null && DateTo != DateTime.MinValue) ? ConvertDatetime.ConvertToGregorianDate((DateTime)DateTo) : DateTo; var _model = new LoggingViewModel { DateFrom = DateFrom, DateTo = DateTo, RowID = RowId, LoggingAction = LoggingAction, LoggingCategory = LoggingCategory }; var _Data = await loggingService.SearchInLogging(DateFrom, DateTo, RowId, LoggingAction, LoggingCategory); _model.LoggingList = _Data.Select(a => new LoggingViewModelItems { ID = a.ID, ActionDate = a.ActionDate, LoggingAction = a.LoggingAction, LoggingCategory = a.LoggingCategory, RowID = a.RowID, UserName = a.UserData?.FirstName + " " + a.UserData?.SecondName + " " + a.UserData?.ThirdName, }).ToPagedList(page, Constants.PageSize); return(View(_model)); }
public async Task <List <PermissionGroup> > Search(string Name = null, DateTime?StartDate = null, DateTime?EndDate = null) { var PermissionGroup = await repository. GetAllWhereAsync <PermissionGroup>(i => (i.isActive == true) && (string.IsNullOrEmpty(Name) || i.Name.ToLower().Contains(Name.ToLower())) && (StartDate.HasValue == false || i.StartDate == ConvertDatetime.ConvertToGregorianDate(StartDate.Value)) && (EndDate.HasValue == false || i.EndDate == ConvertDatetime.ConvertToGregorianDate(EndDate.Value))); return(PermissionGroup); }