public List <LogBookDto> SearchLogBook(LogBookSearchParameter param) => _uow.Uow(uow => { var dtos = uow.LogBookRepository.Search(param) .Select(lb => new LogBookDto { Boatings = lb.Boatings.Select(b => new BoatingDto { BoatingId = b.BoatingId, LogBookId = b.LogBookId, MemberId = b.MemberId, Seat = b.Seat, Order = b.Order, Member = new MemberDto { MemberId = b.MemberId, FirstName = b.Member.FirstName, MiddleInitial = b.Member.MiddleInitial, LastName = b.Member.LastName } }).ToList(), BoatName = lb.BoatName, BoatType = lb.BoatType, Comment = lb.Comment, Date = lb.Date, LogBookId = lb.LogBookId, MilesRowed = lb.MilesRowed ?? 0, TimeOut = lb.TimeOut ?? lb.Date, TimeIn = lb.TimeIn ?? lb.Date }) .ToList(); return(dtos); });
public IQueryable <LogBook> Search(LogBookSearchParameter param) { var query = Context.Set <LogBook>().AsQueryable(); if (param == null) { return(query); } if (param.StartDate.HasValue) { query = query.Where(lb => lb.Date >= param.StartDate.Value); } if (param.EndDate.HasValue) { query = query.Where(lb => lb.Date <= param.EndDate.Value); } if (!string.IsNullOrEmpty(param.BoatName)) { query = query.Where(lb => lb.BoatName == param.BoatName); } if (!string.IsNullOrEmpty(param.BoatType)) { query = query.Where(lb => lb.BoatType == param.BoatType); } if (param.MemberId.HasValue) { query = query.Where(lb => lb.Boatings.Any(b => b.MemberId == param.MemberId.Value)); } if (!string.IsNullOrEmpty(param.Comment)) { query = query.Where(lb => lb.Comment.Contains(param.Comment)); } return(query); }
public List <LogBookDto> SearchLogBook(LogBookSearchParameter param) { var logBooks = VesperLogBookService.SearchLogBook(param); return(logBooks); }