public Response <PatientConsultationDto> DeleteCheck(PatientConsultationDto patientConsultationDto) { Response <PatientConsultationDto> response = new Response <PatientConsultationDto>(); if (patientConsultationDto == null || patientConsultationDto.PatientConsultationId == null || patientConsultationDto.PatientConsultationId.Value == int.MinValue) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The entry you trying to delete does not exist." }); return(response); } using (UnitOfWork unitOfWork = new UnitOfWork()) { PatientConsultation patientConsultation = unitOfWork.PatientConsultationRepository.GetByID(p => p.PatientConsultationId == patientConsultationDto.PatientConsultationId.Value, "Patient, Doctor"); if (patientConsultation == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The entry you trying to delete does not exist." }); return(response); } } return(response); }
public Response <PatientConsultationDto> SavePatientConsultation(PatientConsultationDto patientConsultationDto) { Response <PatientConsultationDto> response = _PatientConsultationBusinessRules.SaveCheck(patientConsultationDto); if (response.HasErrors) { return(response); } switch (patientConsultationDto.CrudOperation) { case CrudOperations.Create: response.Model = Create(patientConsultationDto); break; case CrudOperations.Update: response.Model = Update(patientConsultationDto); break; case CrudOperations.Delete: Delete(patientConsultationDto); break; default: throw new ArgumentException("Invalid crud operation."); } return(response); }
public Response <PatientConsultationDto> SaveCheck(PatientConsultationDto patientConsultationDto) { Response <PatientConsultationDto> response = new Response <PatientConsultationDto>(); if (patientConsultationDto == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The entry you trying to save does not exist." }); return(response); } switch (patientConsultationDto.CrudOperation) { case CrudOperations.Create: return(CreateCheck(patientConsultationDto)); case CrudOperations.Update: return(UpdateCheck(patientConsultationDto)); case CrudOperations.Delete: return(DeleteCheck(patientConsultationDto)); default: throw new ArgumentException("Invalid crud operation."); } }
private void Delete(PatientConsultationDto patientConsultationDto) { using (TransactionScope scope = new TransactionScope()) { using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.PatientMedicalAidDependancyRepository.Delete(patientConsultationDto.PatientConsultationId.Value); unitOfWork.Save(); } scope.Complete(); } }
public PatientConsultationDto MapToPatientConsultationDto(PatientConsultation patientConsultation) { if (patientConsultation == null) { return(null); } PatientConsultationDto patientConsultationDto = new PatientConsultationDto(); patientConsultationDto.PatientConsultationId = patientConsultation.PatientConsultationId; patientConsultationDto.DoctorId = patientConsultation.DoctorId; patientConsultationDto.PatientId = patientConsultation.PatientId; patientConsultationDto.ConsultationStatus = patientConsultation.ConsultationStatus; patientConsultationDto.StartDate = patientConsultation.StartDate; patientConsultationDto.EndDate = patientConsultation.EndDate; return(patientConsultationDto); }
public PatientConsultationViewModel MapToPatientConsultationViewModel(PatientConsultationDto patientConsultationDto) { if (patientConsultationDto == null) { return(null); } PatientConsultationViewModel patientConsultationViewModel = new PatientConsultationViewModel(); CrudOperationsMapper crudOperationsMapper = new CrudOperationsMapper(); patientConsultationViewModel.PatientConsultationId = patientConsultationDto.PatientConsultationId; patientConsultationViewModel.PatientId = patientConsultationDto.PatientId; patientConsultationViewModel.DoctorId = patientConsultationDto.DoctorId; patientConsultationViewModel.ConsultationStatus = patientConsultationDto.ConsultationStatus; patientConsultationViewModel.StartDate = Converter.DateToString(patientConsultationDto.StartDate); patientConsultationViewModel.EndDate = Converter.DateToString(patientConsultationDto.EndDate); patientConsultationViewModel.CrudOperation = crudOperationsMapper.MapToModelCrudOperations(patientConsultationDto.CrudOperation); return(patientConsultationViewModel); }
public PatientConsultationDto MapToPatientConsultationDto(PatientConsultationViewModel patientConsultationViewModel) { if (patientConsultationViewModel == null) { return(null); } PatientConsultationDto patientConsultationDto = new PatientConsultationDto(); CrudOperationsMapper crudOperationsMapper = new CrudOperationsMapper(); patientConsultationDto.PatientConsultationId = patientConsultationViewModel.PatientConsultationId; patientConsultationDto.PatientId = patientConsultationViewModel.PatientId == null? int.MinValue : patientConsultationViewModel.PatientId.Value; patientConsultationDto.DoctorId = patientConsultationViewModel.DoctorId == null ? int.MinValue : patientConsultationViewModel.DoctorId.Value; patientConsultationDto.ConsultationStatus = patientConsultationViewModel.ConsultationStatus; patientConsultationDto.StartDate = Converter.StringToDate(patientConsultationViewModel.StartDate); patientConsultationDto.EndDate = Converter.StringToDate(patientConsultationViewModel.EndDate); patientConsultationDto.CrudOperation = crudOperationsMapper.MapToCrudOperations(patientConsultationViewModel.CrudOperation); return(patientConsultationDto); }
private PatientConsultationDto Create(PatientConsultationDto patientConsultationDto) { PatientConsultationDto addedPatientConsultationDto = null; PatientConsultation patientConsultation = new PatientConsultation(); _PatientConsultationMapper.MapToPatientConsultation(patientConsultation, patientConsultationDto); using (TransactionScope scope = new TransactionScope()) { using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.PatientConsultationRepository.Insert(patientConsultation); unitOfWork.Save(); addedPatientConsultationDto = _PatientConsultationMapper.MapToPatientConsultationDto(unitOfWork.PatientConsultationRepository.GetByID(p => p.PatientConsultationId == patientConsultation.PatientConsultationId)); } scope.Complete(); } return(addedPatientConsultationDto); }
private PatientConsultationDto Update(PatientConsultationDto patientConsultationDto) { PatientConsultationDto updatedPatientConsultationDto = null; using (TransactionScope scope = new TransactionScope()) { using (UnitOfWork unitOfWork = new UnitOfWork()) { PatientConsultation patientConsultation = unitOfWork.PatientConsultationRepository.GetByID(p => p.PatientConsultationId == patientConsultationDto.PatientConsultationId); _PatientConsultationMapper.MapToPatientConsultation(patientConsultation, patientConsultationDto); unitOfWork.PatientConsultationRepository.Update(patientConsultation); unitOfWork.Save(); updatedPatientConsultationDto = _PatientConsultationMapper.MapToPatientConsultationDto(unitOfWork.PatientConsultationRepository.GetByID(p => p.PatientConsultationId == patientConsultation.PatientConsultationId)); } scope.Complete(); } return(updatedPatientConsultationDto); }
public Response <PatientConsultationDto> SavePatientConsultation(PatientConsultationDto patientConsultationDto) { return(_IPatientConsultationManager.SavePatientConsultation(patientConsultationDto)); }
public void MapToPatientConsultation(PatientConsultation patientConsultation, PatientConsultationDto patientConsultationDto) { if (patientConsultationDto == null) { return; } patientConsultation = patientConsultation ?? new PatientConsultation(); patientConsultation.DoctorId = patientConsultationDto.DoctorId; patientConsultation.PatientId = patientConsultationDto.PatientId; patientConsultation.ConsultationStatus = patientConsultationDto.ConsultationStatus; patientConsultation.StartDate = patientConsultationDto.StartDate.Value; patientConsultation.EndDate = patientConsultationDto.EndDate.Value; }
public Response <PatientConsultationDto> CreateCheck(PatientConsultationDto patientConsultationDto) { Response <PatientConsultationDto> response = new Response <PatientConsultationDto>(); if (patientConsultationDto == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The entry you trying to create does not exist." }); return(response); } if (string.IsNullOrEmpty(patientConsultationDto.ConsultationStatus)) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { FieldName = "ConsultationStatus", ErrorMessage = "Status is requeired." }); } if (patientConsultationDto.StartDate == DateTime.MinValue) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { FieldName = "StartDate", ErrorMessage = "Start Date is required." }); } if (patientConsultationDto.EndDate == DateTime.MinValue) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { FieldName = "EndDate", ErrorMessage = "End Date is required." }); } if (response.HasErrors) { return(response); } using (UnitOfWork unitOfWork = new UnitOfWork()) { Patient patient = unitOfWork.PatientRepository.GetByID(p => p.PatientId == patientConsultationDto.PatientId); if (patient == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "There is no corresponding patient for the consultation." }); return(response); } Doctor doctor = unitOfWork.DoctorRepository.GetByID(p => p.DoctorId == patientConsultationDto.DoctorId); if (doctor == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "There is no corresponding doctor for the consultation." }); return(response); } } return(response); }