public async Task <Result <Core.Models.VisitDetails> > Handle(EditVisitDetailsCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    Core.Models.VisitDetails visitDetails = await _unitOfWork.Repository <Core.Models.VisitDetails>()
                                                            .Get(x => x.Id == request.VisitDetails.Id).FirstOrDefaultAsync();

                    if (visitDetails != null)
                    {
                        visitDetails.VisitNumber    = request.VisitDetails.VisitNumber;
                        visitDetails.VisitType      = request.VisitDetails.VisitType;
                        visitDetails.DaysPostPartum = request.VisitDetails.DaysPostPartum;
                    }

                    _unitOfWork.Repository <Core.Models.VisitDetails>().Update(visitDetails);
                    await _unitOfWork.SaveAsync();

                    return(Result <Core.Models.VisitDetails> .Valid(visitDetails));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <Core.Models.VisitDetails> .Invalid(e.Message));
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put([FromBody] EditVisitDetailsCommand visitDetailsCommandEdit)

        {
            var results = await _mediator.Send(visitDetailsCommandEdit, Request.HttpContext.RequestAborted);

            if (results.IsValid)
            {
                return(Ok(results.Value));
            }
            return(BadRequest(results));
        }