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

            r.Description = "TestReturn";
            int id = manager.Create(r);

            var actual = manager.GetById(id);

            Assert.IsNotNull(actual);
            Assert.AreEqual("TestReturn", actual.Description);
        }
コード例 #2
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            RatingManager manager = new RatingManager();
            Rating        rating  = new Rating {
                Description = RatingTextBox.Text
            };

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