Пример #1
0
        public void TestTrackedEntitiesByType()
        {
            ContactInformation contactInformation1 = new ContactInformation()
            {
                Phone = "phone1", Email = "*****@*****.**"
            };
            var customer1 = new Customer()
            {
                Name = "Customer1", ContactInformation = contactInformation1
            };
            ContactInformation contactInformation2 = new ContactInformation()
            {
                Phone = "phone1", Email = "*****@*****.**"
            };
            var customer2 = new Customer()
            {
                Name = "Customer1", ContactInformation = contactInformation2
            };
            Technology technology = new Technology();

            technology.Name = "Name";

            customerRepository.Add(customer1);
            customerRepository.Add(customer2);

            technologyRepository.Add(technology);

            var customersTracked = customerRepository.UnitOfWork.Local <Customer>();

            customersTracked.Should().NotBeEmpty()
            .And.HaveCount(2)
            .And.ContainItemsAssignableTo <Customer>();
        }
Пример #2
0
        public ActionResult Add(Technology technology)
        {
            ValidateTechnology(technology);

            if (ModelState.IsValid)
            {
                _technologyRepository.Add(technology);

                TempData["Message"] = "Your technology has been added.";

                return(RedirectToAction("Details", new { id = technology.Id }));
            }

            return(View(technology));
        }