예제 #1
0
        public ActionResult EditReview(Guid id)
        {
            ViewBag.Title = "Edit Customer Review";

            var model = new CustomerReview();
            using (var db = new DataDBContext())
            {
                var review = db.Items.Find(id);
                model.ReviewId = review.ItemId;
                model.Quote = review.Content01;
                model.Client = review.Content02;
            }

            return View(model);
        }
예제 #2
0
        public ActionResult EditReview(CustomerReview model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new DataDBContext())
                {
                    var target = db.Items.Find(model.ReviewId);
                    target.Content01 = model.Quote;
                    target.Content02 = model.Client;
                    db.SaveChanges();
                }
                return RedirectToAction("Home");
            }

            return View(model);
        }
예제 #3
0
        public ActionResult CreateReview(CustomerReview model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new DataDBContext())
                {
                    var newItem = new Item();
                    newItem.ItemId = Guid.NewGuid();
                    newItem.Content01 = model.Quote;
                    newItem.Content02 = model.Client;
                    newItem.Category = "Review";
                    db.Items.Add(newItem);
                    db.SaveChanges();
                }
                return RedirectToAction("Home");
            }

            return View(model);
        }