Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description")] Event @event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@event).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(@event));
 }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Surname")] Author author)
 {
     if (ModelState.IsValid)
     {
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
Ejemplo n.º 3
0
        public ActionResult Edit(Author author, int[] writtenEvents)
        {
            Author newAuthor = db.Authors.Find(author.Id);

            newAuthor.Name    = author.Name;
            newAuthor.Surname = author.Surname;

            newAuthor.Events.Clear();
            if (writtenEvents != null)
            {
                //получаем написанные события
                foreach (var c in db.Events.Where(co => writtenEvents.Contains(co.Id)))
                {
                    newAuthor.Events.Add(c);
                }
            }

            db.Entry(newAuthor).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit(Author author)
 {
     if (ModelState.IsValid)
     {
         foreach (Book book in author.Books)
         {
             if (book.Id == -1)
             {
                 db.Books.Add(book);
             }
         }
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }