Пример #1
0
 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
        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>()
            };
        }