/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="type"></param> /// <returns></returns> public ApiResponse <List <PersonWithIdentfiersResult> > GetPersonBySpecificIdentifiers(TestProjectDbContext context, IdentifiersType type) { try { var result = _repository.GetPersonBySpecificIdentifiers(context, type).Select(x => new PersonWithIdentfiersResult { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Identifiers = x.Identifiers.Select(a => new IdentifierResult { Id = a.Id, Type = a.Type, Value = a.Value }) }).ToList(); return(ApiResponse <List <PersonWithIdentfiersResult> > .SuccessResult(result)); } catch (Exception ex) when(ex is FailException || ex is ValidationException || ex is ArgumentException) { return(ApiResponse <List <PersonWithIdentfiersResult> > .ErrorResult(message : ex.Message, statusCode : HttpStatusCode.BadRequest)); } catch (Exception ex) when(ex is ErrorException) { //LoggingManager.Error(ex.ToString()); return(ApiResponse <List <PersonWithIdentfiersResult> > .ErrorResult(message : ex.Message)); } catch (Exception ex) { //LoggingManager.Error(ex.ToString()); return(ApiResponse <List <PersonWithIdentfiersResult> > .ErrorResult(message : ex.Message)); } }
/// <summary> /// GetPersonBySpecificIdentifiers /// </summary> /// <param name="context"></param> /// <param name="enumType"></param> /// <returns></returns> public IList <Person> GetPersonBySpecificIdentifiers(TestProjectDbContext context, IdentifiersType enumType) { return(context.Person.Where(x => x.Identifiers.Any(i => i.Type == enumType) && !x.Deleted).ToList()); }
public IActionResult Get(IdentifiersType type) { var response = _personFacades.GetPersonBySpecificIdentifiers(_context, type); return(new ObjectResult(response)); }