コード例 #1
0
 public ActionResult Edit([Bind(Include = "HugId,Hugee,HugTypeId,HugDate")] Hugsmodel hugsmodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hug).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.HugTypeId = new SelectList(db.HugTypes, "HugTypeId", "HugType1", hug.HugTypeId);
     return(View(hug));
 }
コード例 #2
0
        public ActionResult Create([Bind(Include = "HugId,Hugee,HugTypeId,HugDate")] Hugsmodel hugsmodel)
        {
            if (hugsmodel == null)
            {
                throw new ArgumentNullException(nameof(hugsmodel));
            }
            if (ModelState.IsValid)
            {
                db.Hugs.Add(hug);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HugTypeId = new SelectList(db.HugTypes, "HugTypeId", "HugType1", hug.HugTypeId);
            return(View(hug));
        }