public async Task <IActionResult> GetAllPatientJournals(GetAllPatientJournalslWithCapViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } AllPatientJournals patientJournals = await _aerendeService.GetAllPatientJournalsWithCap(model.Cap); if (patientJournals.IsNull) { return(new JsonResult(await Errors .GetGenericErrorResponse( new GetAllPatientJournalsResponse() { PatientJournals = patientJournals.PatentJournals, StatusCode = 422, Error = "Get patient journals error", Description = "Unable to return Patient journals", Code = "get_pateint_journals_error" }))); } return(new JsonResult(Wrappyfier.WrapPatientJournalsResponse(patientJournals))); }
/// <summary> /// /// </summary> /// <param name="cap"></param> /// <returns></returns> public async Task <AllPatientJournals> GetAllPatientJournalsWithCap(int cap) { AllPatientJournals patientJournals = await TryCatch <ArgumentNullException, AllPatientJournals>(async() => { List <PatientJournal> patientJournalsFromDatabase = await AerendeRepository.GetAllPatientJournalWithCap(cap); return(new AllPatientJournals() { PatentJournals = patientJournalsFromDatabase }); }); return(patientJournals ?? new AllPatientJournals()); }
public static GetAllPatientJournalsResponse WrapPatientJournalsResponse(AllPatientJournals patientJournals) { GetAllPatientJournalsResponse listViewModel = new GetAllPatientJournalsResponse() { PatientJournals = patientJournals.PatentJournals, StatusCode = 200, Error = "No error", Description = "All existing patient journals", Code = "no_error" }; return(listViewModel); }