public ActionResult Delete(int id)
        {
            WypozyczeniaModels ownerModel = db.Wypozyczenia.Find(id);

            db.Wypozyczenia.Remove(ownerModel);
            db.SaveChanges();                       //zapis zmian
            return(RedirectToAction("Moje_filmy"));
        }
 public ActionResult Edit([Bind(Include = "FilmID, UzytkownicyID")] WypozyczeniaModels ownerModelUpdated)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ownerModelUpdated).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Moje_filmy"));
     }
     return(View(ownerModelUpdated));
 }
 public ActionResult Create([Bind(Include = "FilmID, UzytkownicyID")] WypozyczeniaModels ownerModel)
 {
     if (ModelState.IsValid)
     {
         db.Wypozyczenia.Add(ownerModel);
         db.SaveChanges();                       //zapis zmian
         return(RedirectToAction("Moje_filmy"));
     }
     return(View(ownerModel));       //zostaną dane w formularzu
 }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Moje_filmy"));
            }

            WypozyczeniaModels ownerModel = db.Wypozyczenia.Find(id);

            if (ownerModel == null)
            {
                return(HttpNotFound());
            }
            return(View(ownerModel));
        }
        public ActionResult Index(int filmID)
        {
            WypozyczeniaModels wypozycz = new WypozyczeniaModels();

            var    username = User.Identity.GetUserName();
            int    userId   = (from x in db.Uzytkownik where x.Nazwa == username select x.ID).SingleOrDefault();
            string date     = DateTime.Today.ToString("yyyy-MM-dd");
            string tytul    = (from x in db.Film where x.ID == filmID select x.Tytul).SingleOrDefault();

            wypozycz.FilmID     = filmID;
            wypozycz.Film_Tytul = tytul;

            wypozycz.UzytkownicyID = userId;
            wypozycz.Data          = date;

            db.Wypozyczenia.Add(wypozycz);
            db.SaveChanges();

            return(RedirectToAction("Moje_filmy"));
        }