public async Task <ResponseResult <bool> > Save(SaveCustomerCommand param) { //Test await _mediator.Send(param); return(ResponseResult <bool> .Success()); }
public NewCustomerView(Customer customer, SaveCustomerCommand saveCommand, DeleteAllCommand deleteCommand) { InitializeComponent(); DataContext = this; CurrentCustomer = customer; SaveCommand = saveCommand; }
public CustomerMasterDetailsViewModel() { _catalog = new CustomerCatalog(); _customerItemViewModel = new CustomerItemViewModel(new Customer()); _deleteCommand = new DeleteCustomerCommand(_catalog, this); _newCommand = new NewCustomerCommand(_catalog, this); _saveCommand = new SaveCustomerCommand(_catalog); _refreshCommand = new RefreshCustomerCommand(this, _catalog); RefreshCustomerItemViewModelCollection(); _catalog.Load(); }
private async Task <ResponseMessage> SaveCustomer(UserSaveIntegrationEvent message) { var customerCommand = new SaveCustomerCommand(message.AggregateId, message.Name, message.Email, message.IdentityNumber); CommandResult <ValidationResult> result; using (var scope = _serviceProvider.CreateScope()) // Create scope inside the singleton (Lifecicle scope) { //Basically service locator is used When it is outside the context or when the class cannot pass arguments through the constructor var mediator = scope.ServiceProvider.GetRequiredService <IMediatorHandler>(); result = await mediator.SendCommand <SaveCustomerCommand, ValidationResult>(customerCommand); } var responseMessage = new ResponseMessage(result.ValidationResult); responseMessage.AggregateId = message.AggregateId; return(responseMessage); }
/// <summary> /// SaveCustomer /// </summary> /// <param name="customer"></param> /// <returns></returns> public async Task <CommandResponse <Customer> > SaveCustomer(SaveCustomerCommand customer) { try { return(await service.CustomerResource.SaveAsync(customer)); } catch (ApiException ex) { apiException = new APIExceptions { ErrorCode = ex.Code, ErrorDescription = ex.Message, ErrorApi = "SaveAsync" }; return(null); } catch (Exception ex) { logger.WriteLogError("**** LoyaltyEngineServices FAILURE: SaveCustomer Exception Error= " + ex.Message); if (ex.InnerException != null) { logger.WriteLogError("**** InnerException = " + ex.InnerException.Message); } return(null); } }