示例#1
0
        public Task <PagedList <DeliveryNote> > GetDeliveryNotes(DeliveryNoteParams param)
        {
            var dns = _context.DeliveryNotes
                      .Include(l => l.DeliveryNoteLines)
                      .Include(c => c.Customer)
                      .Include(s => s.Status)
                      .Where(dn =>
                             param.SearchString != null && (
                                 param.SearchString == string.Empty ||
                                 dn.DnNo.Contains(param.SearchString) ||
                                 dn.Remark.Contains(param.SearchString) ||
                                 dn.InternalMemo.Contains(param.SearchString) ||
                                 dn.SalesPIC.Contains(param.SearchString)
                                 ) ||
                             (
                                 param.SearchString == null && (
                                     (param.CustomerId == 0 || dn.CustomerId == param.CustomerId) &&
                                     (string.IsNullOrEmpty(param.SalesPIC) || dn.SalesPIC == param.SalesPIC) &&
                                     //(string.IsNullOrEmpty(param.Status) || param.Status.Contains(dn.Status.ToString())) &&
                                     (param.DnDateFrom == null || dn.DnDate >= param.DnDateFrom.Value) &&
                                     (param.DnDateTo == null || dn.DnDate <= param.DnDateTo.Value) &&
                                     (param.dueDateFrom == null || dn.DueDate >= param.dueDateFrom.Value) &&
                                     (param.dueDateTo == null || dn.DueDate <= param.dueDateTo.Value) &&
                                     (param.BalanceFrom == null || dn.Balance >= param.BalanceFrom.Value) &&
                                     (param.BalanceTo == null || dn.Balance <= param.BalanceTo.Value)
                                     )
                             )
                             );

            return(PagedList <DeliveryNote> .CreateListAsync(dns, param.PageNumber, param.PageSize));
        }
示例#2
0
        public async Task <IActionResult> GetDns(DeliveryNoteParams param)
        {
            var dns = await _dnRepo.GetDeliveryNotes(param);

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

            var ret = _mapper.Map <List <DeliveryNoteResource> >(dns);

            //ret.ForEach(s =>
            //    s.StatusName = (_statusRepo.GetStatusName(s.StatusCode)).StatusName);
            return(Ok(ret));
        }