コード例 #1
0
        public ActionResult Create(guesttable guest)
        {
            try
            {
                // TODO: Add insert logic here
                using (aptadbEntities aptadb = new aptadbEntities())
                {
                    aptadb.guesttable.Add(guest);
                    aptadb.SaveChanges();
                    //return View(aptadb.authortable.ToList());
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #2
0
        public ActionResult Edit(int?id, guesttable guest)
        {
            try
            {
                // TODO: Add update logic here
                using (aptadbEntities aptadb = new aptadbEntities())
                {
                    //return View(aptadb.authortable.Where(x => x.authorid == id).FirstOrDefault());
                    aptadb.Entry(guest).State = EntityState.Modified;
                    aptadb.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #3
0
        public ActionResult Delete(int?id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                using (aptadbEntities aptadb = new aptadbEntities())
                {
                    //aptadb.authortable.Add(author);
                    guesttable gsttable = aptadb.guesttable.Where(x => x.guestid == id).FirstOrDefault();
                    aptadb.guesttable.Remove(gsttable);
                    aptadb.SaveChanges();
                    //return View(aptadb.authortable.ToList());
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }