protected override void Context()
        {
            Username = "******";

            base.Context();

            CustomerService.Stub(
                x => x.UpdateCustomer(Arg<string>.Is.Equal(Username), Arg<UpdateCustomerRequest>.Is.Anything))
                .WhenCalled(x => _requestPassedToCustomerService = x.Arguments[1] as UpdateCustomerRequest);

            _updateCustomerInputModel = Builder<UpdateCustomerInputModel>.CreateNew().Build();
            _expectedRequest = new UpdateCustomerRequest
                                   {
                                       Id = _updateCustomerInputModel.CustomerId,
                                       Name = _updateCustomerInputModel.Name,
                                   };

            _expectedRequest.AddContact(new Contact
                                            {
                                                Id = _updateCustomerInputModel.ContactId,
                                                FirstName = _updateCustomerInputModel.ContactFirstName,
                                                LastName = _updateCustomerInputModel.ContactLastName,
                                                Phone = _updateCustomerInputModel.ContactPhone,
                                            });

            _expectedRequest.MailingAddress = new Address
                                                  {
                                                      Id = _updateCustomerInputModel.CustomerId,
                                                      Street = _updateCustomerInputModel.Street,
                                                      AdditionalInfo = _updateCustomerInputModel.AdditionalInfo,
                                                      City = _updateCustomerInputModel.City,
                                                      State = _updateCustomerInputModel.State,
                                                      Zipcode = _updateCustomerInputModel.Zipcode,
                                                  };
        }
        protected override void Context()
        {
            Username = "******";

            base.Context();

            _updateCustomerInputModel = Builder<UpdateCustomerInputModel>.CreateNew().Build();
            CustomerService.Stub(
                x => x.UpdateCustomer(Arg<string>.Is.Equal(Username), Arg<UpdateCustomerRequest>.Is.Anything))
                .Throw(new ObjectNotFoundException());
        }
        protected override void Context()
        {
            Username = "******";

            base.Context();

            _updateCustomerInputModel = Builder<UpdateCustomerInputModel>.CreateNew().Build();

            //CustomerService.Stub(
            //    x => x.UpdateCustomer(Arg<string>.Is.Equal(Username), Arg<UpdateCustomerRequest>.Is.Anything))
            //    .Throw(new ValidationException(ValidationErrorMessage));
        }
Пример #4
0
        public ActionResult ProcessUpdateCustomerInput(UpdateCustomerInputModel updateCustomerInputModel)
        {
            return TryThis(() =>
                               {
                                   try
                                   {
                                       UpdateCustomerRequest request =
                                           _mappingEngine.Map<UpdateCustomerInputModel, UpdateCustomerRequest>(updateCustomerInputModel);
                                       request.AddContact(
                                           _mappingEngine.Map<UpdateCustomerInputModel, Contact>(updateCustomerInputModel));

                                       UpdateCustomer(User.Identity.Name, request);

                                       TempData["Message"] = "Customer has been updated successfully";

                                       return RedirectToAction("CustomerManagement", "Customer");
                                   }
                                   catch (ValidationException validationException)
                                   {
                                       var viewModel =
                                           new UpdateCustomerViewModel(new List<string> {validationException.Message});
                                       return View("UpdateCustomer", viewModel);
                                   }
                               });
        }