Guest User

Untitled

a guest
Jun 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1.         // GET: /Answer/Create
  2.  
  3.         public ActionResult Create()
  4.         {
  5.             ViewBag.Ksiazki = new SelectList(db.Ksiazki, "Tytul", "Tytul");
  6.             ViewBag.Ksiazki = new SelectList(db.Klienci, "Imie", "Imie");
  7.             return View();
  8.         }
  9.  
  10.         //
  11.         // POST: /Answer/Create
  12.  
  13.         [HttpPost]
  14.         public ActionResult Create(Ksiazka answer)
  15.         {
  16.             if (ModelState.IsValid)
  17.             {
  18.                 db.Ksiazki.Add(answer);
  19.                 db.SaveChanges();
  20.                 return RedirectToAction("Index");
  21.             }
  22.  
  23.             ViewBag.Ksiazki = new SelectList(db.Ksiazki, "Tytul", "Tytyl", answer.Tytul);
  24.             return View(answer);
  25.         }
  26.         public ActionResult Create(Klient answer)
  27.         {
  28.             if (ModelState.IsValid)
  29.             {
  30.                 db.Klienci.Add(answer);
  31.                 db.SaveChanges();
  32.                 return RedirectToAction("Index");
  33.             }
  34.  
  35.             ViewBag.Klienci = new SelectList(db.Klienci, "Imie", "Imie", answer.Imie);
  36.             return View(answer);
  37.         }
Add Comment
Please, Sign In to add comment