コード例 #1
0
        public List<ItemLog> GetItemLogs(DateFilter filter)
        {
            try
            {
                var query = repository.AsQueryOver<ItemLog>()
                                      .Where(f => f.DeletedOn == null 
                                          //&& f.Item.DeletedOn == null
                                          );

                if (filter.DateFrom != DateTime.MinValue)
                {
                    query = query.Where(f => f.CreatedOn >= filter.DateFrom);
                }

                if (filter.DateTo != DateTime.MinValue)
                {
                    filter.DateTo = filter.DateTo.AddDays(1).AddSeconds(-1);
                    query = query.Where(f => f.CreatedOn <= filter.DateTo);
                }
                query = query.OrderBy(f => f.CreatedOn).Asc;

                var future = query.Future();

                return future.ToList();
            }
            catch (Exception ex)
            {
                throw new ItemException("Failed to retrieve item logs.", ex);
            }
        }
コード例 #2
0
        public virtual ActionResult ExportLogsToCsv(DateFilter model)
        {
            model = model ?? new DateFilter();
            var entities = itemLogService.GetItemLogs(model);

            var entitiesViewModel = EntityToViewModelMapper.Mapper.Map(entities, new List<ItemLogViewModel>());

            var date = DateTime.Now.ToShortDateString().Replace(@"/", @"-");

            return new CsvResult<ItemLogViewModel>(entitiesViewModel)
            {
                FileDownloadName = string.Format("Ataskaita_{0}.csv",  date)
            };
        }
コード例 #3
0
        public virtual ActionResult List(DateFilter model)
        {
            model = model ?? new DateFilter();
            var entities = itemLogService.GetItemLogs(model);

            var entitiesViewModel = EntityToViewModelMapper.Mapper.Map(entities, new List<ItemLogViewModel>());

            var viewModel = new ItemLogListViewModel
                {
                    DateFilter = model,
                    Logs = entitiesViewModel
                };

            return View(viewModel);
        }