Ejemplo n.º 1
0
        public void SaveAuthor(Author author)
        {
            if (author.Id == 0)
            {
                db.Author.Add(author);
            }
            else
            {

                Author dbEntry = db.Author.Find(author.Id);
                if (dbEntry != null)
                {

                    dbEntry.Name = author.Name;
                }
            }

            db.SaveChanges();
        }
Ejemplo n.º 2
0
 public ActionResult EditAuthor(Author author)
 {
     if (ModelState.IsValid)
     {
         SaveAuthor(author);
         TempData["message"] = string.Format("{0} has been saved", author.Name);
         return RedirectToAction("Index");
     }
     else
     {
         // there is something wrong with the data values
         return View(author);
     }
 }