public async Task <IActionResult> Put(int id, [FromBody] CustomerRequest customer) { if (id == customer.Id && TryValidateModel(customer)) { var customerCommand = new CustomerUpdateCommand(customer.Id, customer.FirstName, customer.LastName, customer.BirthDay); var updated = await _mediator.Send(customerCommand); var accountAdded = await AccountSendIfExists(customer.Id, customer.BankAccount, true); return(Ok(updated && accountAdded)); } ModelState.AddModelError("Customer.Id", $"Cutomer.Id '{customer.Id}' and id '{id}' must be the same !"); return(BadRequest(ModelState)); }
/// <summary> /// Fills the customer's properties. /// </summary> /// <param name="customer">The customer.</param> /// <param name="cmd">The command.</param> /// <param name="info">The information.</param> private void FillCustomerProperties(Customer customer, CustomerUpdateCommand cmd, InfoAccumulator info) { FillPersonalDetails(customer, cmd.PersonalDetails, info); FillContactDetails(customer, cmd.ContactDetails); // UpdateAddressInfo(customer, command.Address); if (info.HasErrors) { return; } if (cmd.AlibabaInfo != null) { customer.AlibabaId = cmd.AlibabaInfo.AlibabaId; customer.IsAlibaba = cmd.AlibabaInfo.IsAlibaba; } if (cmd.Cookies != null) { customer.GoogleCookie = cmd.Cookies.GoogleCookie; customer.ReferenceSource = cmd.Cookies.ReferenceSource; } }
public async Task Put(CustomerUpdateCommand command) { await _customerHanlder.Handler(command); }
public async Task <IActionResult> Put(CustomerUpdateCommand command) { var response = await _mediator.Send(command); return(Ok(response)); }
public CustomerViewModel() { customer = new Customer("Thomas"); UpdateCommand = new CustomerUpdateCommand(this); }
/// <summary> /// Initializes a new instance of the CustomerViewModel class. /// </summary> public CustomerViewModel() { _Customer = new Customer("Van"); UpdateCommand = new CustomerUpdateCommand(this); }
public CustomerViewModel() { customer = new Customer("Daniel"); UpdateCommand = new CustomerUpdateCommand(this); }
public CustomerViewModel() { _customer = new Customer("Gabriel"); childVM = new CustomerInfoViewModel(); UpdateCommand = new CustomerUpdateCommand(this); }
public CustomerViewModel(String name) { customer = new Customer(name); UpdateCommand = new CustomerUpdateCommand(this); }
/// <summary> /// Fills the customer property status and time at address and get addresses. /// </summary> /// <param name="command">The command.</param> /// <param name="customer">The customer.</param> /// <param name="customerId">The customer identifier.</param> /// <returns></returns> private IEnumerable <CustomerAddress> FillCustomerPropertyStatusAndTimeAtAddressAndGetAddresses(CustomerUpdateCommand command, Customer customer, int customerId) { bool? isOwnsCurrentAdress = null; bool? isOwnsPreviousAddress = null; bool? isOwnsAdditionalProperty = null; HousingType?currentAddressHousingType = null; var curLivingAddress = command.CurrentLivingAddress .AsOptional() .IfNotEmpty(o => { isOwnsCurrentAdress = o.IsOwns; //Fills time at address customer.PersonalInfo.TimeAtAddress = o.MonthsAtAddress.IsNotEmpty() ? int.Parse(o.MonthsAtAddress) : (int?)null; currentAddressHousingType = o.HousingType; }) .Map(o => ConvertToCustomerAddress(o, customerId)) .IfNotEmpty(addr => addr.addressType = CustomerAddressType.PersonalAddress); var previousLivingAddress = command.PreviousLivingAddress .AsOptional() .IfNotEmpty(o => isOwnsPreviousAddress = o.IsOwns) .Map(o => ConvertToCustomerAddress(o, customerId)) .IfNotEmpty(addr => addr.addressType = CustomerAddressType.PrevPersonAddresses); var additionalOwnedPropertyAddresses = command.AdditionalOwnedProperties .AsOptionals() .IfAnyNotEmpty(() => isOwnsAdditionalProperty = true) .MapMany(o => { var addr = ConvertToCustomerAddress(o, customerId); addr.addressType = CustomerAddressType.OtherPropertyAddress; return(addr); }); CustomerPropertyStatus submitted = DetermineSubmittedPropertyStatus(currentAddressHousingType, isOwnsCurrentAdress, isOwnsPreviousAddress, isOwnsAdditionalProperty); CustomerPropertyStatus final = DetermineNewCustomerPropertyStatus(submitted, (CustomerPropertyStatus)customer.PersonalInfo.PropertyStatus); customer.PersonalInfo.PropertyStatus = (int)final; var addresses = curLivingAddress.Concat(previousLivingAddress) .Concat(additionalOwnedPropertyAddresses.SelectMany(o => o)); return(addresses); }
public Task <ICommandHandlerAggregateAnswer> HandleAsync(CustomerUpdateCommand command) { throw new System.NotImplementedException(); }
private CustomerInfoViewModel childViewModel; //this will manage the view after clicking the button public CustomerViewModel() { customer = new Customer(); childViewModel = new CustomerInfoViewModel(); UpdateCommand = new CustomerUpdateCommand(this); }
public CustomerViewModel() { Customer = new Customer("David"); CustomerUpdateCommand = new CustomerUpdateCommand(this); }
/// <summary> /// Initializes a new instance of the CustomerViewModel class /// </summary> public CustomerViewModel() { _Customer = new Customer("Harish Chand"); UpdateCommand = new CustomerUpdateCommand(this); }