Beispiel #1
0
        public async Task <IActionResult> Post([FromBody] AddVisitDetailsCommand 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 <Core.Models.VisitDetails> > Handle(AddVisitDetailsCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    //PatientPregnancy patientPregnancy = _unitOfWork.Repository<PatientPregnancy>()
                    //    //.Get(x => x.PatientId == request.PatientId).FirstOrDefault();

                    Core.Models.VisitDetails visitDetails = new Core.Models.VisitDetails()
                    {
                        CreateDate           = DateTime.Now,
                        CreatedBy            = request.UserId,
                        DaysPostPartum       = request.DaysPostPartum,
                        DeleteFlag           = false,
                        PregnancyId          = request.PregnancyId,
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        VisitNumber          = request.VisitNumber,
                        VisitType            = request.VisitType,
                        VisitDate            = request.VisitDate,
                        ServiceAreaId        = request.ServiceAreaId
                    };

                    await _unitOfWork.Repository <Core.Models.VisitDetails>().AddAsync(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));
                }
            }
        }