コード例 #1
0
 public UpdateContactQueryResult(IList<County> counties, IList<Country> countries)
 {
     Counties = counties;
     Countries = countries;
     Command = new UpdateContactCommand();
 }
コード例 #2
0
        public WhenUserRequestsToUpdateAnExistingContactWithInvalidContact()
        {
            _contactRepository = Mock.Of<IContactRepository>();
            var countyRepository = Mock.Of<ICountyRepository>();
            Mock.Get(countyRepository)
                .Setup(q => q.GetById(1))
                .Returns(new County(1, "Merseyside"));

            var countryRepository = Mock.Of<ICountryRepository>();
            Mock.Get(countryRepository)
                .Setup(q => q.GetById(1))
                .Returns(new Country(1, "UK"));

            var commandInvoker = new CommandInvoker(new ContactService(countyRepository,
                countryRepository,
                _contactRepository,
                new ValidationService(),
                new ContactAdministrationService(countyRepository,
                    countryRepository,
                    _contactRepository)));

            Mock.Get(countyRepository).Setup(q => q.GetAll()).Returns(_counties);
            Mock.Get(countryRepository).Setup(q => q.GetAll()).Returns(_countries);

            _updateCommand = new UpdateContactCommand
            {
                Id = 1,
                FirstName = "",
                Surname = "",
                Address1 = "Address 1",
                Address2 = "Address 2",
                CountyId = 1,
                CountryId = 1,
            };
            _result = commandInvoker.Execute<UpdateContactCommand, UpdateContactQueryResult>(_updateCommand);
        }
コード例 #3
0
 public ActionResult Update(UpdateContactCommand command)
 {
     var response = commandInvoker.Execute<UpdateContactCommand, UpdateContactQueryResult>(command);
     return ModelState.IsValid ? RedirectToAction("Index") : (ActionResult)View(response);
 }