public IEnumerable <StudentViewModel> Search([FromQuery] string name = null, [FromQuery] string email = null, [FromQuery] string phone = null) { var predicateBuilder = new СonjunctionPredicateBuilder(); if (name != null) { predicateBuilder.AddPropertyEqComparation((StudentViewModel x) => x.Name, name); } if (email != null) { predicateBuilder.AddPropertyEqComparation((StudentViewModel x) => x.Email, email); } if (phone != null) { predicateBuilder.AddPropertyEqComparation((StudentViewModel x) => x.Email, phone); } if (!predicateBuilder.IsEmpty) { return(_appService.List((Expression <Predicate <StudentViewModel> >)predicateBuilder.Lambda)); } else { return(_appService.List <StudentViewModel>()); } }
public IEnumerable <LectionViewModel> Search([FromQuery] string name = null, [FromQuery] int?courseId = null, [FromQuery] DateTime?date = null) { var predicateBuilder = new СonjunctionPredicateBuilder(); if (name != null) { predicateBuilder.AddPropertyEqComparation((LectionViewModel x) => x.Name, name); } if (courseId != null) { predicateBuilder.AddPropertyEqComparation((LectionViewModel x) => x.CourseId, courseId.Value); } if (date != null) { predicateBuilder.AddPropertyEqComparation((LectionViewModel x) => x.Date, date.Value); } if (!predicateBuilder.IsEmpty) { return(_appService.List <LectionViewModel>((Expression <Predicate <LectionViewModel> >)predicateBuilder.Lambda)); } else { return(_appService.List <LectionViewModel>()); } }