コード例 #1
0
ファイル: VesselService.cs プロジェクト: cobianwae/Pear
 public GetVesselsResponse GetVessels(GetVesselsRequest request)
 {
     if (request.OnlyCount)
     {
         return new GetVesselsResponse { Count = DataContext.Vessels.Count() };
     }
     else
     {
         var query = DataContext.Vessels
             .Include(x => x.Measurement);
         if (!string.IsNullOrEmpty(request.Term))
         {
             query = query.Where(x => x.Name.Contains(request.Term));
         }
         query = query.OrderByDescending(x => x.Id).Skip(request.Skip).Take(request.Take);
         return new GetVesselsResponse
         {
             Vessels = query.ToList().MapTo<GetVesselsResponse.VesselResponse>()
         };
     }
 }
コード例 #2
0
ファイル: VesselService.cs プロジェクト: cobianwae/Pear
        public GetVesselsResponse GetVesselsForGrid(GetVesselsRequest request)
        {
            int totalRecords;
            var data = SortData(request.Search, request.SortingDictionary, out totalRecords);
            if (request.Take != -1)
            {
                data = data.Skip(request.Skip).Take(request.Take);
            }

            return new GetVesselsResponse
            {
                TotalRecords = totalRecords,
                Vessels = data.ToList().MapTo<GetVesselsResponse.VesselResponse>()
            };
        }