Ejemplo n.º 1
0
 /// <summary>
 /// Get sales order list by user
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public async Task <dynamic> GetSalesOrderByUserIdAsync(string userId, int?orderStatus, string type, int step, int begin)
 {
     try
     {
         var result = context.Pomst.Where(p => p.CreaPo == userId && p.TypePo == type && (orderStatus == null || p.StatPo == orderStatus.ToString())).Select(p => new
         {
             commandeTypeId     = p.TypePo,
             commandeTypeLabel  = utils.GetCommandTypeLabelById(p.TypePo),
             commandeId         = p.PonbPo,
             commandeCreateDate = p.DatePo,
             updateOn           = p.LdatPo.HasValue ? p.LdatPo.Value.ToString("yyyy-MM-dd hh:mm:ss") : "[N/A]",
             updateTime         = p.LdatPo,
             receiver           = p.TnamPo,
             status             = this.utils.GetOrdersStatus(Int32.Parse(p.StatPo)),
             type            = p.TcpyPo, // 单位
             creator         = context.User.Where(x => x.Id == userId).Select(y => y.Name),
             commandeCreator = p.FnamPo  //context.Personel.Where(r=>r.EmpnPsl == p.CreaPo).Select(x=>x.NamePsl)
         }).OrderByDescending(x => x.updateTime);
         var filterResult = new
         {
             data       = await result.Skip(begin *step).Take(step).ToListAsync <dynamic>(),
             totalCount = await result.CountAsync()
         };
         return(filterResult);
     }
     catch (Exception e)
     {
         throw e;
     }
 }