Example #1
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            try
            {
                Restauracja restauracja = db.Restauracje.Where(x => x.ID == id).FirstOrDefault();

                restauracja.Nazwa          = collection["Nazwa"];
                restauracja.Link           = collection["Link"];
                restauracja.Miasto         = collection["Miasto"];
                restauracja.Email          = collection["Email"];
                restauracja.Przyjecia      = collection["Przyjecia"];
                restauracja.iloscStolikow  = Int32.Parse(collection["iloscStolikow"]);
                restauracja.MaxLiczbaGosci = Int32.Parse(collection["MaxLiczbaGosci"]);
                restauracja.rodzajKuchni   = collection["rodzajKuchni"];
                restauracja.DodatkoweUwagi = collection["DodatkoweUwagi"];

                db.Entry(restauracja).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index", "Restauracje"));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        public ActionResult Create(IFormCollection collection)
        {
            try
            {
                var id = _userManager.GetUserId(User);

                Restauracja restauracja = new Restauracja();
                restauracja.Nazwa          = collection["Nazwa"];
                restauracja.Link           = collection["Link"];
                restauracja.Miasto         = collection["Miasto"];
                restauracja.Email          = collection["Email"];
                restauracja.Przyjecia      = collection["przyjecie"];
                restauracja.iloscStolikow  = Int32.Parse(collection["iloscStolikow"]);
                restauracja.MaxLiczbaGosci = Int32.Parse(collection["MaxLiczbaGosci"]);
                restauracja.rodzajKuchni   = collection["rodzajKuchni"];
                restauracja.klimatLokalu   = collection["klimatLokalu"];
                restauracja.DodatkoweUwagi = collection["DodatkoweUwagi"];
                restauracja.Adder          = id;
                restauracja.Termin         = DateTime.Today;

                db.Restauracje.Add(restauracja);
                db.SaveChanges();

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Example #3
0
        public ActionResult Delete(int id, IFormCollection collection)
        {
            try
            {
                Restauracja res = db.Restauracje.Where(x => x.ID == id).FirstOrDefault();
                if (res != null)
                {
                    db.Restauracje.Remove(res);
                    db.SaveChanges();
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #4
0
        // GET: Restauracje/Edit/5
        public ActionResult Edit(int id)
        {
            Restauracja restauracja = db.Restauracje.Where(x => x.ID == id).FirstOrDefault();

            return(View(restauracja));
        }