コード例 #1
0
        public void Get_By_Id_Returns_Existing()
        {
            Director d = new Director();

            d.FirstName = "TestReturn";
            d.LastName  = "Test";
            int id = manager.Create(d);

            var actual = manager.GetById(id);

            Assert.IsNotNull(actual);
            Assert.AreEqual("TestReturn", actual.FirstName);
        }
コード例 #2
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            DirectorManager manager  = new DirectorManager();
            Director        director = new Director {
                FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text
            };

            manager.Create(director);
            DoDataBind();
            manager.Dispose();
        }
コード例 #3
0
 public ActionResult Create(Director director)
 {
     if (ModelState.IsValid)
     {
         using (manager = new DirectorManager())
         {
             manager.Create(director);
         }
         if (director == null)
         {
             return(HttpNotFound());
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         return(View(director.Id));
     }
 }