public async Task <IActionResult> AddPersonLocation([FromBody] AddPersonLocationCommand addPersonLocationCommand) { var response = await _mediator.Send(addPersonLocationCommand, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public async Task <Result <AddPersonLocationResponse> > Handle(AddPersonLocationCommand request, CancellationToken cancellationToken) { try { using (_unitOfWork) { //PersonLocation personLocation = new PersonLocation() //{ // PersonId = request.PersonId, // County = request.CountyId, // SubCounty = request.SubCountyId, // Ward = request.WardId, // Village = request.Village, // Location = "", // SubLocation = "", // LandMark = request.LandMark, // NearestHealthCentre = "", // Active = false, // DeleteFlag = false, // CreateDate = DateTime.Now, // CreatedBy = request.UserId //}; //await _unitOfWork.Repository<PersonLocation>().AddAsync(personLocation); //await _unitOfWork.SaveAsync(); RegisterPersonService personService = new RegisterPersonService(_unitOfWork); var personLocation = await personService.addPersonLocation(request.PersonId, request.CountyId, request.SubCountyId, request.WardId, request.Village, request.LandMark, request.UserId); _unitOfWork.Dispose(); return(Result <AddPersonLocationResponse> .Valid(new AddPersonLocationResponse() { PersonLocationId = personLocation.Id })); } } catch (Exception e) { return(Result <AddPersonLocationResponse> .Invalid(e.Message)); } }