protected ActionResult DisplayDetails(AddressDTO item)
        {
            var vm = GetViewModelFromTempData<AddressViewModel>();
            if (vm == null) { return RedirectToReferrer(); }

            vm.DisplayName = Strings.AddressDetailViewModel_DisplayName;
            vm.SelectedItem = item;

            // Finish Action
            StoreViewModelToTempData(vm);
            TempData.Keep();
            return View(vm);
        }
        public static Address DtoToAddress(AddressDTO dto)
        {
            Address address = new Address
                                  {
                                      AddressId = dto.Id,
                                      AddressLine1 = dto.AddressLine1,
                                      AddressLine2 = dto.AddressLine2,
                                      PostalCode = dto.PostalCode,
                                      City = dto.City,
                                      Phone = dto.Phone,
                                      Email = dto.Email,
                                      Version = dto.Version
                                  };

            ValidationHelper.Validate(address);
            return address;
        }
        public void TestDtoToCustomer()
        {
            AddressDTO addressDto = new AddressDTO() { Id = 1, AddressLine1 = "FakeStreet", PostalCode = "FakePostalCode", City = "FakeCity", Phone = "FakePhone", Email = "FakeEmail", Version = 0 };
            CustomerDTO dto = new CustomerDTO() { Id = 1, Name = "FakeUsername", FirstName = "FakeFirstname", Version = 1 };
            dto.Addresses.Add(addressDto);
            Assert.AreEqual(true, dto.IsValid);
            Assert.AreEqual(true, addressDto.IsValid);

            Customer customer = CustomerAdapter.DtoToCustomer(dto);
            Assert.AreEqual<int>(dto.Id, customer.CustomerId);
            Assert.AreEqual<string>(dto.Name, customer.Name);
            Assert.AreEqual<string>(dto.FirstName, customer.FirstName);
            Assert.AreEqual(dto.Version, customer.Version);
            Assert.AreEqual(true, customer.IsValid);

            //Assert.AreEqual<int>(dto.Addresses.Count(), customer.Addresses.Count());
            //Assert.AreEqual(true, address.IsValid);
        }
        public void TestCustomerDetailModel()
        {
            AddressDTO addressDto = new AddressDTO() {Id = 1, AddressLine1 = "FakeStreet", PostalCode = "FakePostalCode", City = "FakeCity", Phone = "FakePhone", Email = "FakeEmail", Version = 0};
            CustomerDTO dto = new CustomerDTO() {Id = 1, Name = "FakeUsername", FirstName = "FakeFirstname", Version = 1};
            dto.Addresses.Add(addressDto);

            CustomerDetailViewModel customerDetailViewModel = new CustomerDetailViewModel(dto, false);
            customerDetailViewModel.Service = serviceFacade;

            Expect.Once.On(serviceFacade).Method("StoreCustomer").With(dto);
            customerDetailViewModel.SaveCommand.Command.Execute(null);

            Assert.AreEqual(dto, customerDetailViewModel.Model);
            Assert.AreEqual(Strings.CustomerDetailViewModel_DisplayName, customerDetailViewModel.DisplayName);

            AddressViewModel addressViewModel = (AddressViewModel) customerDetailViewModel.ListViewModel;
            Assert.AreEqual(addressDto, addressViewModel.Items.FirstOrDefault());
        }
 public void TestAddressDetailViewModel()
 {
     AddressDTO dto = new AddressDTO() {Id = 1, AddressLine1 = "FakeStreet", PostalCode = "FakePostalCode", City = "FakeCity", Phone = "FakePhone", Email = "FakeEmail", Version = 0};
     AddressDetailViewModel viewModel = new AddressDetailViewModel(dto, false);
     Assert.AreEqual(dto, viewModel.Model);
     Assert.AreEqual(Strings.AddressDetailViewModel_DisplayName, viewModel.DisplayName);
 }
 // GET: Address/Create
 public ActionResult Create()
 {
     AddressDTO item = new AddressDTO();
     return DisplayDetails(item);
 }