Пример #1
0
        public ActionResult Edit(int?id, authortable author)
        {
            try
            {
                using (aptadbEntities aptadb = new aptadbEntities())
                {
                    //return View(aptadb.authortable.Where(x => x.authorid == id).FirstOrDefault());
                    aptadb.Entry(author).State = EntityState.Modified;
                    aptadb.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #2
0
        public ActionResult Create(authortable author)
        {
            try
            {
                using (aptadbEntities aptadb = new aptadbEntities())
                {
                    aptadb.authortable.Add(author);
                    aptadb.SaveChanges();
                    //return View(aptadb.authortable.ToList());
                }
                // TODO: Add insert logic here

                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);
                    authortable authortable = aptadb.authortable.Where(x => x.authorid == id).FirstOrDefault();
                    aptadb.authortable.Remove(authortable);
                    aptadb.SaveChanges();
                    //return View(aptadb.authortable.ToList());
                }

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