Inheritance: Entity
        public ActionResult Add(ClientAddModel model)
        {
            if (ModelState.IsValid)
            {
                var client = new Client
                {
                    FirstName = model.FirstName,
                    LastName = model.LastName
                };
                client.Treatments.Add(_treatmentStrategy.GenerateTreatment(client,_repository.Get<Counselor>(model.Counselor)));

                _repository.Add(client);
                _repository.Commit();

                return Redirect<ClientController>(c => c.Index());
            }

            return View(model);
        }
示例#2
0
        public void TestRepositoryClient()
        {
            IRepository repo = ObjectFactory.GetInstance<IRepository>();
            Client newClient = new Client();
            newClient.FirstName = "John";
            newClient.LastName = "Smith";
            repo.Add<Client>(newClient);

            newClient = new Client();
            newClient.FirstName = "Jane";
            newClient.LastName = "Doe";
            repo.Add<Client>(newClient);

            repo.Commit();
            var client = repo.Find<Client>(c => c.Id == 1);
            Assert.AreEqual(client.Count(), 1);

            client = repo.Find<Client>(c => c.Id >= 0);
            Assert.AreEqual(client.Count(), 5);
        }
 protected override void Arrange()
 {
     _strategy = new OzarkRecoveryTreatmentStrategy();
     _client = new Client{ Id=1234, FirstName="John", LastName="Doe"};
     _counselor = new Counselor {Id = 5678, FirstName = "Jane", LastName = "Doe"};
 }
 public void Add(Client entity)
 {
 }