コード例 #1
0
        public bool Create(Inquiry inquiry)
        {
            if (ModelState.IsValid)
            {
                inquiry.House = db.Houses.Include("Location").Single(m => m.ID == inquiry.House.ID);
                inquiry.Status = "Pending";
                db.Inquiries.Add(inquiry);
                db.SaveChanges();
                return true;
            }

            return false;
        }
コード例 #2
0
 public ActionResult Edit(Inquiry inquiry)
 {
     if (ModelState.IsValid)
     {
         Inquiry i = db.Inquiries.Include("House").Single(m => m.ID == inquiry.ID);
         db.Entry(i).CurrentValues.SetValues(inquiry);
         db.SaveChanges();
         Success("Response sent!");
         return RedirectToAction("Index");
     }
     Error("Something went wrong! No response was sent");
     return View(inquiry);
 }