public ActionResult RestorantEdit(int?restorantID, Restorant x) { int sess = Convert.ToInt32(Session["userID"]); try { var restorantlar = db.Restorants.Where(m => m.restorantID == restorantID).SingleOrDefault(); restorantlar.restorantAd = x.restorantAd; restorantlar.restorantIl = x.restorantIl; restorantlar.restorantIlce = x.restorantIlce; restorantlar.restorantAdres = x.restorantAdres; restorantlar.restorantTelefon = x.restorantTelefon; restorantlar.restorantKahvaltiFiyat = x.restorantKahvaltiFiyat; restorantlar.restorantAksamFiyat = x.restorantAksamFiyat; restorantlar.restorantOglenFiyat = x.restorantOglenFiyat; restorantlar.restorantFiyatBirimi = x.restorantFiyatBirimi; restorantlar.userID = sess; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View(x)); } }
public ActionResult Create(Restorant restorant, HttpPostedFileBase restorantFoto) { int sess = Convert.ToInt32(Session["userID"]); if (ModelState.IsValid) { if (restorantFoto != null) { WebImage img = new WebImage(restorantFoto.InputStream); FileInfo fotoinfo = new FileInfo(restorantFoto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(150, 150); img.Save("~/Uploads/RestorantPhoto/" + newfoto); restorant.restorantFoto = "/Uploads/RestorantPhoto/" + newfoto; restorant.userID = sess; restorant.isDeleted = false; db.Restorants.Add(restorant); db.SaveChanges(); return(RedirectToAction("Index", "Restorant")); } else { restorant.userID = sess; restorant.isDeleted = false; db.Restorants.Add(restorant); db.SaveChanges(); return(RedirectToAction("Index", "Restorant")); } } return(View(restorant)); }
public JsonResult DeleteRestorantRecord(int restorantID) { bool result = false; Restorant res = db.Restorants.SingleOrDefault(x => x.restorantID == restorantID); if (res != null) { res.isDeleted = true; db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public IActionResult UyeOL(string ad, string email, string password, string adress, string tur) { var restorant = new Restorant(); restorant.Ad = ad; restorant.Email = email; restorant.Password = password; restorant.Adress = adress; restorant.Tur = tur; _ctx.Restorants.Add(restorant); _ctx.SaveChanges(); HttpContext.Session.SetString("restorant-email", email); return(Redirect("/")); }