public CreateCustomerValidationDecorator( ICommandHandlerAsync <CreateCustomerCommand> commandHandler, IValidationHandler <CreateCustomerCommand> validationHandler) { _commandHandler = commandHandler; _validationHandler = validationHandler; }
private async Task <int> LogError(HttpContext httpContext, ILogger <ErrorMiddleware> logger, IDispatcher dispatcher, UserManager <User> userManager, ICommandHandlerAsync <AddErrorCmd> addErrorCmdHandler, Exception exception) { var userId = await GetUserId(httpContext, userManager); var addErrorCmd = new AddErrorCmd(); addErrorCmd.Exception = exception; addErrorCmd.Url = httpContext.Request.Path.Value + httpContext.Request.QueryString.Value; addErrorCmd.UserId = userId; await dispatcher.PushAsync(addErrorCmdHandler, addErrorCmd); var error = (ErrorLog)addErrorCmd.Result; logger.LogError($"id = {error.Id}" + $" | logged_date = {error.LoggedDate}" + $" | user_id = {error.UserId}" + $" | summary = {error.ErrorSummary}" + $" | location = {error.ErrorLocation}" + $" | url = {error.Url}"); return(error.Id); }
public SendSmsCommandHandlerWithWaitForPreviousSms( ICommandHandlerAsync <SendSmsCommand> handler, INotificationClient notificationClient) { _handler = handler; _notificationClient = notificationClient; }
public LoggingCommandHandlerDecorator( ICommandHandlerAsync <T> decoratedCommandHandler, ICommandLogger commandLogger) { _decoratedCommandHandler = decoratedCommandHandler; _commandLogger = commandLogger; }
public async Task <IActionResult> Create( [FromServices] ICommandHandlerAsync <CreatePurchaseOrderCommand> createCommandHandler, CreatePurchaseOrderCommand createCommand) { var result = await createCommandHandler.HandleAsync(createCommand); return(RedirectToAction("Index")); }
public async Task <IActionResult> DeleteConfirmed( [FromServices] ICommandHandlerAsync <DeleteInventoryItemCommand> deleteCommandHandler, DeleteInventoryItemCommand deleteCommand) { var result = await deleteCommandHandler.HandleAsync(deleteCommand); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit( [FromServices] ICommandHandlerAsync <EditInventoryItemCommand> editCommandHandler, EditInventoryItemCommand editCommand) { await editCommandHandler.HandleAsync(editCommand); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create( [FromServices] ICommandHandlerAsync <CreateInventoryItemCommand> createCommandHandler, CreateInventoryItemCommand createCommand) { await createCommandHandler.HandleAsync(createCommand); return(RedirectToAction("Index")); }
public async Task <IActionResult> SignOut(SignOutCmd cmd, [FromServices] ICommandHandlerAsync <SignOutCmd> handler) { var user = await GetCurrentUserAsync(); await this._dispatcher.PushAsync(handler, cmd); _logger.LogInformation($"User \"{user.Email}\" signed out"); return(Json(new Json())); }
public FeedbackServiceTests() { this.dataConfig = Options.Create(new DataOptions()); this.azureConfig = Options.Create(new AzureOptions()); this.feedbackRepo = Substitute.For <IFeedbackRepository>(); this.saveFeedbackCommandHandler = new SaveFeedbackCommandHandler(this.feedbackRepo); sut = new Services.FeedbackService.FeedbackService(saveFeedbackCommandHandler); }
public CommandAsync( ILoggerFactory loggerFactory, IComponentContext componentContext, ICommandHandlerAsync commandHandlerAsync ) { _loggerFactory = loggerFactory; _componentContext = componentContext; _commandHandlerAsync = commandHandlerAsync; }
public DatabaseControlAsync( ILoggerFactory loggerFactory, IComponentContext componentContext, ICommandHandlerAsync commandHandlerAsync ) { _loggerFactory = loggerFactory; _componentContext = componentContext; _commandHandlerAsync = commandHandlerAsync; _logger = _loggerFactory.CreateLogger <DatabaseControlAsync>(); }
public SendSmsCommandHandlerWithDelayHandler( ICommandHandlerAsync <SendSmsCommand> handler, IQueueClientFactory queueClientFactory, ILoggerFactory logFactory, ISettingService settingService) { _handler = handler; _queueClient = queueClientFactory.Create <SmsOutgoingMessage>(); _log = logFactory.CreateLogger <SendSmsCommandHandlerWithDelayHandler>(); _settingService = settingService; }
public BizAsync( ILoggerFactory loggerFactory, IComponentContext componentContext, ICommandHandlerAsync commandHandlerAsync ) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <BizAsync>(); _componentContext = componentContext; _commandHandlerAsync = commandHandlerAsync; }
public async Task <IActionResult> Delete(int id, [FromBody] DeleteTaskCmd cmd, [FromServices] ICommandHandlerAsync <DeleteTaskCmd> handler) { if (id != cmd.Id) { throw new CustomException((int)ExceptionCode.Validation, "id mismatch"); } await this._dispatcher.PushAsync(handler, cmd); _logger.LogInformation($"Delete Task with id = {id}"); return(Json(new Json())); }
public AppointmentsController( IIdentifierGenerationService identifierGenerationService, ICommandHandlerAsync <ScheduleAppointmentCommand> scheduleAppointmentCommandHandler, IQueryHandlerAsync <GetAppointmentQuery, AppointmentReadModel> getAppointmentQueryHandler, IQueryHandlerAsync <GetAppointmentsForDoctorQuery, IReadOnlyList <AppointmentReadModel> > getAllAppointmentsForDoctorQueryHandler, IQueryHandlerAsync <GetAppointmentsForPatientQuery, IReadOnlyList <AppointmentReadModel> > getAllAppointmentsForPatientQueryHandler) { _identifierGenerationService = identifierGenerationService; _scheduleAppointmentCommandHandler = scheduleAppointmentCommandHandler; _getAppointmentQueryHandler = getAppointmentQueryHandler; _getAllAppointmentsForDoctorQueryHandler = getAllAppointmentsForDoctorQueryHandler; _getAllAppointmentsForPatientQueryHandler = getAllAppointmentsForPatientQueryHandler; }
public async Task <IActionResult> SignIn([FromBody] SignInCmd cmd, [FromServices] ICommandHandlerAsync <SignInCmd> handler) { if (!ModelState.IsValid) { var errors = GetErrors(); throw new CustomException((int)ExceptionCode.Validation, errors); } await this._dispatcher.PushAsync(handler, cmd); _logger.LogInformation($"User \"{cmd.UserName}\" signed in"); return(Json(new Json())); }
public async Task <IActionResult> Post([FromBody] CreateTaskCmd cmd, [FromServices] ICommandHandlerAsync <CreateTaskCmd> handler) { if (!ModelState.IsValid) { var errors = GetErrors(); throw new CustomException((int)ExceptionCode.Validation, errors); } cmd.Validate(); await this._dispatcher.PushAsync(handler, cmd); _logger.LogInformation("Create task"); return(Json(new Json(cmd.Result))); }
public async Task Invoke(HttpContext httpContext, ILogger <ErrorMiddleware> logger, IDispatcher dispatcher, UserManager <User> userManager, ICommandHandlerAsync <AddErrorCmd> addErrorCmdHandler) { try { await this._next(httpContext); } catch (Exception exception) { var jsonErrors = new List <JsonError.ErrorItem>(); var errorId = await LogError(httpContext, logger, dispatcher, userManager, addErrorCmdHandler, exception); if (exception is CustomException) { var customException = (CustomException)exception; jsonErrors.Add(new JsonError.ErrorItem(errorId, customException.Message)); switch ((ExceptionCode)customException.Code) { case ExceptionCode.Validation: httpContext.Response.StatusCode = 400; //Bad Request break; case ExceptionCode.NotFound: httpContext.Response.StatusCode = 404; //Not Found break; default: httpContext.Response.StatusCode = 500; //Internal Server Error break; } } else { jsonErrors.Add(new JsonError.ErrorItem(errorId, exception.Message)); httpContext.Response.StatusCode = 500; //Internal Server Error } var result = new JsonError(jsonErrors); var json = JsonConvert.SerializeObject(result); httpContext.Response.ContentType = "application/json"; await httpContext.Response.WriteAsync(json).ConfigureAwait(false); } }
public static async Task Run( [ServiceBusTrigger("%OutgoingMessageQueueName%", Connection = "ServiceBusConnection")] Message queueMessage, ILogger log, [Inject] ICommandHandlerAsync <SendSmsCommand> commandHandler) { try { var outgoingSms = JsonConvert.DeserializeObject <OutgoingSms>(Encoding.UTF8.GetString(queueMessage.Body)); await commandHandler.HandleAsync(new SendSmsCommand(outgoingSms, queueMessage)); } catch (Exception e) { log.LogError($"SendSmsMessage ERROR", e, e.Message); throw new BotConnectorException("Something went wrong when relaying the message to the Notify client", e); } }
public static async Task Run( [TimerTrigger("%DailySurveyTriggerSchedule%")] TimerInfo myTimer, [Inject] ICommandHandlerAsync <TriggerSurveyInvitesCommand> commandHandler, ILogger log, ExecutionContext executionContext) { try { log.LogInformation("Daily survey trigger started"); await commandHandler.HandleAsync(new TriggerSurveyInvitesCommand()); log.LogInformation("Daily survey trigger complete"); } catch (Exception ex) { log.LogError(ex, ex.Message); throw ex; } }
public TransactionAsync( ILoggerFactory loggerFactory, IComponentContext componentContext, IConnectionFactory connectionFactory, IExchangeComDeclareParameters exchangeDeclareParameters, IQueueComDeclareParameters queueDeclareParameters, ICommandHandlerAsync commandHandlerAsync, ITagGroupReady tagGroupReady ) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <TransactionAsync>(); _componentContext = componentContext; _connectionFactory = connectionFactory; _exchangeDeclareParameters = exchangeDeclareParameters; _queueDeclareParameters = queueDeclareParameters; _commandHandlerAsync = commandHandlerAsync; _tagGroupReady = tagGroupReady; //LoadGroups(); }
public SendSmsCommandHandlerWithLocking(ICommandHandlerAsync <SendSmsCommand> handler, IDistributedLockProvider lockProvider) { _handler = handler; _lockProvider = lockProvider; }
public ContactController(ICommandHandlerAsync <CreateContactCommand> createContactCommandHandler) { _createContactCommandHandler = createContactCommandHandler; }
public AuditCommandLoggingDecorator( ICommandHandlerAsync <TCommand, TResult> handler, ILogger logger) { _handler = handler; _logger = logger; }
public ContactControllerTests() { _createContactCommandHandler = Substitute.For <ICommandHandlerAsync <CreateContactCommand> >(); _contactController = new ContactController(_createContactCommandHandler); }
public SendSmsCommandHandlerWithOrderCheck(ICommandHandlerAsync <SendSmsCommand> handler, IConversationRepository conversationRepository) { _handler = handler; _conversationRepository = conversationRepository; }
public TestCommandDecorator(ICommandHandlerAsync <TestCommand, int> handler) { _handler = handler; }
public async Task PushAsync <TCommand>(ICommandHandlerAsync <TCommand> commandHandlerAsync, TCommand message) { await commandHandlerAsync.HandleAsync(message); }
public NotifySmsService( ICommandHandlerAsync <SendBasicSmsCommand> sendSmsCommandHandler) { this.sendSmsCommandHandler = sendSmsCommandHandler; }