Example #1
0
        public async Task <IActionResult> Post([FromBody] AddHeiPatientIptCommand addHeiPatientIptCommand)
        {
            var response = await _mediator.Send(addHeiPatientIptCommand, Request.HttpContext.RequestAborted);

            if (response)
            {
                return(Ok(response.Value));
            }
            return(BadRequest(response.Value));
        }
        public async Task <Result <PatientIpt> > Handle(AddHeiPatientIptCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    await _unitOfWork.Repository <PatientIpt>().AddAsync(request.PatientIpt);

                    await _unitOfWork.SaveAsync();

                    return(Result <PatientIpt> .Valid(request.PatientIpt));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Result <PatientIpt> .Invalid(e.Message));
                }
            }
        }