예제 #1
0
        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));
        }
예제 #2
0
        /// <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;
            }
        }
예제 #3
0
 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));
        }
예제 #5
0
 public CustomerViewModel()
 {
     customer      = new Customer("Thomas");
     UpdateCommand = new CustomerUpdateCommand(this);
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the CustomerViewModel class.
 /// </summary>
 public CustomerViewModel()
 {
     _Customer     = new Customer("Van");
     UpdateCommand = new CustomerUpdateCommand(this);
 }
예제 #7
0
 public CustomerViewModel()
 {
     customer      = new Customer("Daniel");
     UpdateCommand = new CustomerUpdateCommand(this);
 }
 public CustomerViewModel()
 {
     _customer     = new Customer("Gabriel");
     childVM       = new CustomerInfoViewModel();
     UpdateCommand = new CustomerUpdateCommand(this);
 }
예제 #9
0
 public CustomerViewModel(String name)
 {
     customer      = new Customer(name);
     UpdateCommand = new CustomerUpdateCommand(this);
 }
예제 #10
0
        /// <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);
        }
예제 #11
0
 public Task <ICommandHandlerAggregateAnswer> HandleAsync(CustomerUpdateCommand command)
 {
     throw new System.NotImplementedException();
 }
예제 #12
0
        private CustomerInfoViewModel childViewModel; //this will manage the view after clicking the button

        public CustomerViewModel()
        {
            customer       = new Customer();
            childViewModel = new CustomerInfoViewModel();
            UpdateCommand  = new CustomerUpdateCommand(this);
        }
예제 #13
0
 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);
 }