public List <Reason> SearchReason(ReasonSC search) { var result = new List <Reason>(); try { var query = Context.Reason .Include(r => r.ReservationStatus) .AsQueryable(); if (search != null) { if (!string.IsNullOrEmpty(search.Reason)) { query = query.Where(r => r.ReasonText != null && r.ReasonText.Contains(search.Reason)); } if (search.ReservationStatus != null && search.ReservationStatus > 0) { query = query.Where(r => r.ReservationStatusId != null && r.ReservationStatus.Id == search.ReservationStatus); } if (search.Status != null) { query = query.Where(r => r.IsAnswer == search.Status); } } result = query.ToList(); } catch { } return(result); }
public PartialViewResult _ReasonList(ReasonSC search) { ReasonVM[] Reasons = null; try { Reasons = UnitOfWork.ReasonBL.SearchReason(search).Select(b => new ReasonVM(b)).ToArray(); } catch (Exception e) { Reasons = null; } return(PartialView(Reasons)); }