public GetNLSListResponse GetNLSList(GetNLSListRequest request) { if (request.OnlyCount) { return new GetNLSListResponse { Count = DataContext.NextLoadingSchedules.Count() }; } else if (request.VesselScheduleId != 0) { var query = DataContext.NextLoadingSchedules.Include(x => x.VesselSchedule).Include(x => x.VesselSchedule.Vessel); query = query.Where(x => x.VesselSchedule.Id == request.VesselScheduleId).OrderByDescending(x => x.CreatedAt); return new GetNLSListResponse { NLSList = query.ToList().MapTo<GetNLSListResponse.NLSResponse>() }; } else { var query = DataContext.NextLoadingSchedules.Include(x => x.VesselSchedule).Include(x => x.VesselSchedule.Vessel); if (!string.IsNullOrEmpty(request.Term)) { query = query.Where(x => x.VesselSchedule.Vessel.Name.Contains(request.Term)); } query = query.OrderByDescending(x => x.Id).Skip(request.Skip).Take(request.Take); return new GetNLSListResponse { NLSList = query.ToList().MapTo<GetNLSListResponse.NLSResponse>() }; } }
public GetNLSListResponse GetNLSListForGrid(GetNLSListRequest 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 GetNLSListResponse { TotalRecords = totalRecords, NLSList = data.ToList().MapTo<GetNLSListResponse.NLSResponse>() }; }