// GET: KlientUdzial public ActionResult Index() { KlientUdzialViewModel model = new KlientUdzialViewModel(); model.Klient = db.Klient.ToList(); model.Udzial = db.Udzial.ToList(); return(View(model)); }
public ActionResult Transakcja(int?id) { string msg = string.Empty; ViewBag.Exception = null; Udzial udzial = db.Udzial.Find(id); try { db.Entry(udzial).State = EntityState.Modified; int res = db.Database.ExecuteSqlCommand( @"UPDATE Udzial SET IloscOsob = @p0 WHERE Id = @p1" ); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception e) { if (e.InnerException == null) { msg = "Zle dane"; } else { msg = e.InnerException.InnerException.Message; } ViewBag.Exception = msg; } ViewBag.IdKlienta = new SelectList(db.Klient, "IdKlienta", "IdKlienta"); ViewBag.IdWycieczki = new SelectList(db.Wycieczka, "IdWycieczki", "IdWycieczki"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Klient klient = db.Klient.Find(id); if (klient == null) { return(HttpNotFound()); } List <Klient> t = new List <Klient>(); t.Add(db.Klient.Find(id));; KlientUdzialViewModel model = new KlientUdzialViewModel(); model.Klient1 = db.Klient.Find(id); return(View(model)); }