public MainAppPageVM(INavigationService navigationService) { CustomerCommand = new NewCustomerCommand(this); ItemCommand = new NewItemCommand(this); ProviderCommand = new NewProviderCmd(this); QuoteCommand = new NewQuoteCmd(this); this.navigationService = navigationService; }
public static Customer New(NewCustomerCommand command) { var customer = new Customer(); customer.Name = new Name(command.Firstname, command.Lastname); customer.Document = new Document(command.Number); return(customer); }
public CustomerCreatedEvent CreateCustomer(NewCustomerCommand cust) { CustomerCreatedEvent ee = new CustomerCreatedEvent { CustomerId = cust.CustomerId, LastName = cust.LastName, FirstName = cust.FirstName }; apply(ee); return(ee); }
public async Task <CustomerDTO> Post([FromBody] CustomerDTO value) { string firstname = value.Name.Split(" ")[0]; string lastname = value.Name.Split(" ")[1]; ICommand cmd = new NewCustomerCommand(value.CustomerId, firstname, lastname, value.CreditScore); //Customer ee = await repo.InsertCustomer(value); services.Handle(cmd); return(value); }
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(); }
public ActionResult Index() { _connection.Save("ConnectionString", "RepositoryKey"); NewCustomerCommand command = new NewCustomerCommand { RepositoryKey = "gdp2300", Number = "000.000.000-00", Firstname = "Fulano", Lastname = "Silva", AddressLine = "Endereço line 1", AddressLine2 = "Endereço line 2", AddressCode = "72440000" }; _customerService.CreateCustomer(command); return(View()); }
public void CreateCustomer(NewCustomerCommand command) { var customer = Customer.Factory.New(command); var customerRepository = _unitOfWork.GetRepository <ICustomerRepository>(command.RepositoryKey); var addressRepository = _unitOfWork.GetRepository <IAddressRepository>(); try { _unitOfWork.Begin(System.Data.IsolationLevel.ReadUncommitted); customerRepository.Save(customer); addressRepository.Save(Guid.NewGuid(), customer.Address); _unitOfWork.Commit(); } catch (Exception ex) { _unitOfWork.Rollback(); } finally { _unitOfWork.Dispose(); } }
private async Task NewCustomerAsync(NewCustomerCommand newCustomerCommand) { using (var db = _dbContextFactory.Create()) { var customer = new Customer { Name = newCustomerCommand.Name, PhoneNumber = newCustomerCommand.PhoneNumber }; await db.Customers.AddAsync(customer); await db.SaveChangesAsync(); var customerActor = Context.ActorOf(_system.DI().Props <CustomerActor>(), customer.Id.ToString()); _logger.Information("Created new customer with id {customerId}, {name}, {phone}", customer.Id, customer.Name, customer.PhoneNumber); Sender.Tell(new NewCustomerResponse(customer.Id)); _customers.Add(customer.Id, customerActor); } }
public virtual void VisitCustomerCommand(NewCustomerCommand customerCommand) { }
public override void Run() { var storageAccount = CloudStorageAccount.Parse (RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString")); // Get table and queue objects for working with tables and queues. while (!IsStopped) { try { // Receive the message BrokeredMessage receivedMessage = null; receivedMessage = Client.Receive(); if (receivedMessage != null) { // Process the message Trace.WriteLine("Processing", receivedMessage.SequenceNumber.ToString()); NewCustomerCommand command = receivedMessage.GetBody <NewCustomerCommand>(); // Create the table client. CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "Customer" table. CloudTable table = tableClient.GetTableReference("Customer"); // Create a new customer entity. Customer customer = new Customer { Id = Guid.NewGuid().ToString(), PartitionKey = command.LastName, RowKey = command.FirstName, FirstName = command.FirstName, LastName = command.LastName, Address = command.Address, Email = command.Email, Phone = command.Phone }; // Create the TableOperation that inserts the customer entity. TableOperation insertOperation = TableOperation.Insert(customer); // Execute the insert operation. table.Execute(insertOperation); receivedMessage.Complete(); } } catch (MessagingException e) { if (!e.IsTransient) { Trace.WriteLine(e.Message); throw; } Thread.Sleep(10000); } catch (OperationCanceledException e) { if (!IsStopped) { Trace.WriteLine(e.Message); throw; } } } }