Пример #1
0
        public async Task <object> AddPatientCounsellingInfo([FromBody] AddPatientEducationCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(command));
            }
            var response = await _mediator.Send(command, HttpContext.RequestAborted);

            if (response.IsValid)
            {
                return(Ok(response.Value));
            }

            return(BadRequest(response));
        }
        public async Task <Result <AddPatientEducationCommandResult> > Handle(AddPatientEducationCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    PatientEducation patientEducation = new PatientEducation(request.PatientId, request.PatientMasterVisitId, request.CounsellingTopicId, request.CounsellingDate, request.IsCounsellingDone, request.CreatedBy);

                    await _unitOfWork.Repository <PatientEducation>().AddAsync(patientEducation);

                    await _unitOfWork.SaveAsync();

                    return(Result <AddPatientEducationCommandResult> .Valid(new AddPatientEducationCommandResult()
                    {
                        PatientCounsellingId = patientEducation.Id
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <AddPatientEducationCommandResult> .Invalid(e.Message));
                }
            }
        }