public async Task <OutputResponse> Add(PatientStatusDTO patientStatus) { var isFound = await _context.PatientStatuses.AnyAsync(x => x.PatientStatusName.ToLower() == patientStatus.PatientStatusName.ToLower()); if (isFound) { return(new OutputResponse { IsErrorOccured = true, Message = "Patient status name already exist, duplicates not allowed" }); } var mappedPatientStatus = new AutoMapperHelper <PatientStatusDTO, PatientStatuses>().MapToObject(patientStatus); mappedPatientStatus.RowAction = "I"; mappedPatientStatus.DateCreated = DateTime.UtcNow; await _context.PatientStatuses.AddAsync(mappedPatientStatus); await _context.SaveChangesAsync(); return(new OutputResponse { IsErrorOccured = false, Message = MessageHelper.AddNewSuccess }); }
public async Task <OutputResponse> Update(PatientStatusDTO patientStatus) { var patientStatusToUpdate = await _context.PatientStatuses.FirstOrDefaultAsync(x => x.PatientStatusId.Equals(patientStatus.PatientStatusId)); if (patientStatusToUpdate == null) { return(new OutputResponse { IsErrorOccured = true, Message = "Patient status specified does not exist, update cancelled" }); } //update details patientStatusToUpdate.PatientStatusName = patientStatus.PatientStatusName; patientStatusToUpdate.Severity = patientStatus.Severity; patientStatusToUpdate.RowAction = "U"; patientStatusToUpdate.ModifiedBy = patientStatus.CreatedBy; patientStatusToUpdate.DateModified = DateTime.UtcNow; await _context.SaveChangesAsync(); return(new OutputResponse { IsErrorOccured = false, Message = MessageHelper.UpdateSuccess }); }
public async Task <IActionResult> Update([FromBody] PatientStatusDTO patientStatus) { var outputHandler = await _service.Update(patientStatus); if (outputHandler.IsErrorOccured) { return(BadRequest(outputHandler.Message)); } return(Ok(outputHandler.Message)); }
private async Task <PatientStatusDTO> GetPatientStatus(int statusId) { string url = $"{PatientsApiUrl}PatientStatuses/GetById?statusId={statusId}"; var PatientStatuse = new PatientStatusDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Get(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { PatientStatuse = response.ContentAsType <PatientStatusDTO>(); } else { ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(PatientStatuse); }
public async Task <IActionResult> Edit([Bind] PatientStatusDTO patientStatus) { string url = $"{PatientsApiUrl}PatientStatuses/Update"; var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Put(accessToken, url, patientStatus); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Patient status has been successfully updated", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to update patient status", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(patientStatus)); }
public async Task <IActionResult> VerifyDelete(int statusId) { string url = $"{PatientsApiUrl}PatientStatuses/Delete?statusId={statusId}"; var PatientStatuse = new PatientStatusDTO(); var accessToken = await HttpContext.GetTokenAsync("access_token"); var response = await HttpRequestFactory.Delete(accessToken, url); if (response.StatusCode == HttpStatusCode.OK) { AppContextHelper.SetToastMessage("Patient status has been successfully deleted", MessageType.Success, 1, Response); return(RedirectToAction(nameof(Index))); } else { AppContextHelper.SetToastMessage("Failed to delete patient status", MessageType.Danger, 1, Response); ModelState.AddModelError("", HttpResponseHandler.Process(response)); } return(View(await GetPatientStatus(statusId))); }
public PatientStatusDTO DeletePatientStatus(string ID) { StoreContext db = new StoreContext(); PatientStatus patientStatus = db.PatientStatus.Where(a => a.Id == Helper.DecryptInt(ID)).FirstOrDefault(); if (patientStatus != null) { PatientStatusDTO response = mapper.Map <PatientStatusDTO>(patientStatus); db.PatientStatus.Remove(patientStatus); db.SaveChanges(); return(response); } else { return(null); } }
public PatientStatusDTO CreatePatientStatus(PatientStatusCreateDTO info) { StoreContext db = new StoreContext(); if (!string.IsNullOrEmpty(info.Name) || info.Name != "string") { PatientStatus patientStatus = mapper.Map <PatientStatus>(info); db.PatientStatus.Add(patientStatus); db.SaveChanges(); PatientStatusDTO response = mapper.Map <PatientStatusDTO>(patientStatus); return(response); } else { return(null); } }
public PatientStatusDTO UpdatePatientStatus(PatientStatusUpdateDTO info) { StoreContext db = new StoreContext(); PatientStatus patientStatus = db.PatientStatus.Where(a => a.Id == Helper.DecryptInt(info.Id)).FirstOrDefault(); if (patientStatus != null) { patientStatus.Name = info.Name; patientStatus.IsActive = info.IsActive; db.SaveChanges(); PatientStatusDTO response = mapper.Map <PatientStatusDTO>(patientStatus); return(response); } else { return(null); } }
public IActionResult DeletePatientStatus([FromQuery] string ID) { PatientStatusDTO response = repository.DeletePatientStatus(ID); return(new ObjectResult(response)); }
public IActionResult UpdatePatientStatus([FromBody] PatientStatusUpdateDTO info) { PatientStatusDTO response = repository.UpdatePatientStatus(info); return(new ObjectResult(response)); }