public RegisterClientResult Handle(RegisterClientCommand command) { return(new RegisterClientResult { Id = clientService.RegisterClient(command) }); }
public async Task <Result <RegisterClientResponse> > Handle(RegisterClientCommand request, CancellationToken cancellationToken) { try { RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); var facilityList = await _unitOfWork.Repository <Facility>() .Get(x => x.PosID == request.Person.FacilityId.ToString()).ToListAsync(); Facility facility = new Facility(); if (facilityList.Count > 0) { facility = facilityList[0]; } else { facility = await _unitOfWork.Repository <Facility>().Get(x => x.DeleteFlag == 0) .FirstOrDefaultAsync(); } var result = await registerPersonService.RegisterPerson(request.Person.FirstName, request.Person.MiddleName, request.Person.LastName, request.Person.Sex, request.Person.CreatedBy, facility.FacilityID, request.Person.DateOfBirth); _unitOfWork.Dispose(); return(Result <RegisterClientResponse> .Valid(new RegisterClientResponse { PersonId = result.Id })); } catch (Exception e) { return(Result <RegisterClientResponse> .Invalid(e.Message)); } }
public async Task <Result <RegisterClientResponse> > Handle(RegisterClientCommand request, CancellationToken cancellationToken) { try { //var sql = // "exec pr_OpenDecryptedSession;" + // "Insert Into Person(FirstName, MidName,LastName,Sex,DateOfBirth,DobPrecision,Active,DeleteFlag,CreateDate,CreatedBy)" + // $"Values(ENCRYPTBYKEY(KEY_GUID('Key_CTC'), '{request.Person.FirstName}'), ENCRYPTBYKEY(KEY_GUID('Key_CTC'), '{request.Person.MiddleName}')," + // $"ENCRYPTBYKEY(KEY_GUID('Key_CTC'), '{request.Person.LastName}'), {request.Person.Sex}, '{request.Person.DateOfBirth.ToString("yyyy-MM-dd")}', 1," + // $"1,0,GETDATE(), '{request.Person.CreatedBy}');" + // "SELECT [Id] , CAST(DECRYPTBYKEY(FirstName) AS VARCHAR(50)) [FirstName] ,CAST(DECRYPTBYKEY(MidName) AS VARCHAR(50)) MidName" + // ",CAST(DECRYPTBYKEY(LastName) AS VARCHAR(50)) [LastName] ,[Sex] ,[Active] ,[DeleteFlag] ,[CreateDate] " + // ",[CreatedBy] ,[AuditData] ,[DateOfBirth] ,[DobPrecision] FROM [dbo].[Person] WHERE Id = SCOPE_IDENTITY();" + // "exec [dbo].[pr_CloseDecryptedSession];"; //var personInsert = await _unitOfWork.Repository<Person>().FromSql(sql); RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); var result = await registerPersonService.RegisterPerson(request.Person.FirstName, request.Person.MiddleName, request.Person.LastName, request.Person.Sex, request.Person.DateOfBirth, request.Person.CreatedBy); _unitOfWork.Dispose(); return(Result <RegisterClientResponse> .Valid(new RegisterClientResponse { PersonId = result.Id })); } catch (Exception e) { return(Result <RegisterClientResponse> .Invalid(e.Message)); } }
public async Task <IActionResult> Post([FromBody] RegisterClientCommand registerClientCommand) { var response = await _mediator.Send(registerClientCommand, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public Guid RegisterClient(RegisterClientCommand command) { var client = mapper.Map <RegisterClientCommand, Client>(command); unitOfWork.ClientRepository.Insert(client); unitOfWork.Save(); return(client.Id); }
private async Task <ResponseMessage> RegisterClient(UserRegisteredIntegrationEvent message) { var clientCommand = new RegisterClientCommand(message.Id, message.Name, message.Email, message.CPF); ValidationResult success; using (var scope = _provider.CreateScope()) { var mediator = scope.ServiceProvider.GetRequiredService <IMediatorHandler>(); success = await mediator.SendCommand(clientCommand); } return(new ResponseMessage(success)); }
public IActionResult RegisterClient([FromBody] RegisterClientCommand command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = commandProcessor.Process <RegisterClientCommand, RegisterClientResult>(command); Response.StatusCode = StatusCodes.Status201Created; return(new JsonResult(result)); }
public async Task <IActionResult> Post([FromBody] RegisterClientCommand command) { if (!ModelState.IsValid) { return(ErrorModelResult()); } try { var result = await _commandDispatcher.DispatchAsync <RegisterClientCommand, Result>(command); return(ToResult(result)); } catch (FailureResult reqEx) { return(ErrorResult(reqEx)); } }
public async Task <Result <RegisterClientResponse> > Handle(RegisterClientCommand request, CancellationToken cancellationToken) { try { RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); var result = await registerPersonService.RegisterPerson(request.Person.FirstName, request.Person.MiddleName, request.Person.LastName, request.Person.Sex, request.Person.DateOfBirth, request.Person.CreatedBy); _unitOfWork.Dispose(); return(Result <RegisterClientResponse> .Valid(new RegisterClientResponse { PersonId = result.Id })); } catch (Exception e) { return(Result <RegisterClientResponse> .Invalid(e.Message)); } }
public async Task <IActionResult> Register(ClientCreateModel model) { if (ModelState.IsValid) { var cmd = new RegisterClientCommand(model.Name, model.Website, model.Description); var result = await _mediator.Send(cmd); if (result.IsFailure) { ModelState.AddModelError("", result.Error); } else { return(RedirectToAction(nameof(ClientController.Index))); } } return(View(model)); }
public async Task Register(RegisterClientCommand registerClientCommand) { await _bus.SendCommand(registerClientCommand); }
public async Task <ActionResult <RegisterClientCommandVm> > RegisterClient(RegisterClientCommand command) { return(await Mediator.Send(command)); }
public Task <IResponse> Register(RegisterClientCommand command) { return(mediator.Send(command)); }
public async Task <ActionResult> RegisterClient([FromBody] RegisterClientCommand command) => await base.Send(command);