public async Task <IActionResult> GetHistory([FromQuery] HistoryParams historyParams)
        {
            var history = await _srepo.GetHistory(historyParams);

            var historyToReturn = _mapper.Map <IEnumerable <HistoryForListDto> >(history);

            Response.AddPagination(history.CurrentPage, history.PageSize, history.TotalCount, history.TotalPages);

            return(Ok(historyToReturn));
        }
        public async Task <PageList <History> > GetHistory(HistoryParams historyParams)
        {
            var history = _context.History.AsQueryable();

            if (historyParams.Mnf != null)
            {
                history = history.Where(u => u.Mnf == historyParams.Mnf);
            }

            if (historyParams.ReelId != 0)
            {
                history = history.Where(u => u.ReelId == historyParams.ReelId);
            }

            if (historyParams.OldLocation != null)
            {
                history = history.Where(u => u.OldLocation == historyParams.OldLocation);
            }
            if (historyParams.NewLocation != null)
            {
                history = history.Where(u => u.NewLocation == historyParams.NewLocation);
            }

            history = history.OrderByDescending(u => u.DateAdded);

            if (!string.IsNullOrEmpty(historyParams.OrderBy))
            {
                switch (historyParams.OrderBy)
                {
                case "Mnf":
                    history = history.OrderBy(u => u.Mnf);
                    break;

                case "id":
                    history = history.OrderBy(u => u.ReelId);
                    break;

                default:
                    history = history.OrderBy(u => u.DateAdded);
                    break;
                }
            }

            return(await PageList <History> .CreateAsync(history, historyParams.PageNumber, historyParams.PageSize));
        }
示例#3
0
 public async Task <IActionResult> GetMixingInfoByGlueName([FromBody] HistoryParams historyParams)
 {
     return(Ok(await _mixingInfoService.GetMixingInfoByGlueName(historyParams.GlueName)));
 }