Пример #1
0
        public ActionResult Create(Rating rating, int id)
        {
            try
            {

                if (ModelState.IsValid)
                {
                    rating.UserId = (Guid)Membership.GetUser().ProviderUserKey;

                    var amenityRating = db.Amenities.Find(id);
                    rating.AmenityID = amenityRating.AmenityID;

                    db.Ratings.Add(rating);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (DataException)
            {
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("", "Unable to save changes due an unforeseen error.  Please try again.");
            }

            return View(rating);
        }
Пример #2
0
 public void CommentsTest()
 {
     Rating target = new Rating(); // TODO: Initialize to an appropriate value
     string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual;
     target.Comments = expected;
     actual = target.Comments;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #3
0
 public void AmenityIDTest()
 {
     Rating target = new Rating(); // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     target.AmenityID = expected;
     actual = target.AmenityID;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #4
0
        public ActionResult Create(Rating rating)
        {
            if (ModelState.IsValid)
            {
                db.Ratings.Add(rating);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(rating);
        }
Пример #5
0
 public ActionResult Edit(Rating rating)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rating).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(rating);
 }
Пример #6
0
 public void UserIdTest()
 {
     Rating target = new Rating(); // TODO: Initialize to an appropriate value
     Guid expected = new Guid(); // TODO: Initialize to an appropriate value
     Guid actual;
     target.UserId = expected;
     actual = target.UserId;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #7
0
 public void RatingValueTest()
 {
     Rating target = new Rating(); // TODO: Initialize to an appropriate value
     float expected = 0F; // TODO: Initialize to an appropriate value
     float actual;
     target.RatingValue = expected;
     actual = target.RatingValue;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }