public ActionResult AddRestuarant(Restuarant model) { bool Status = false; string messege = ""; if (ModelState.IsValid) { if (model.ImageData != null) { model.Photo = new byte[model.ImageData.ContentLength]; model.ImageData.InputStream.Read(model.Photo, 0, model.ImageData.ContentLength); } else { return(View(model)); } #region Save in Database _db.Restuarants.Add(model); _db.SaveChanges(); #endregion Status = true; messege = "Success"; } else { messege = "Invalid Request"; } ViewBag.Message = messege; ViewBag.Status = Status; return(View(model)); }
public ActionResult DeleteConfirmed(int id) { Restuarant restuarant = db.Restuarants.Find(id); db.Restuarants.Remove(restuarant); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "restaurantID,restaurantName,_class,star,openTime,closeTIme,priceRange")] Restuarant restuarant) { if (ModelState.IsValid) { db.Entry(restuarant).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restuarant)); }
public ActionResult Create([Bind(Include = "Id,Name,Address,City,State,Zip,Phone,Website,Country,ImageUrl")] Restuarant restuarant) { if (ModelState.IsValid) { db.Restuarants.Add(restuarant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restuarant)); }
public ActionResult Create([Bind(Include = "restaurantID,restaurantName,_class,star,openTime,closeTIme,priceRange")] Restuarant restuarant) { if (ModelState.IsValid) { db.Restuarants.Add(restuarant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restuarant)); }
// GET: Restuarants/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Restuarant restuarant = db.Restuarants.Find(id); if (restuarant == null) { return(HttpNotFound()); } return(View(restuarant)); }
public IActionResult RestuarantAndBar(Restuarant model) { if (model.Time == "-1") { ModelState.AddModelError("Time", "Tell us when do want this Service"); } if (ModelState.IsValid) { ViewBag.SpaAppointment = "Thanks"; ModelState.Clear(); } return(View()); }
public ActionResult Edit(Restuarant restuarant, HttpPostedFileBase restuarantImage) { bool isValidDoc = false; string[] formats = new string[] { ".jpg", ".png", ".gif", ".jpeg" }; if (ModelState.IsValid) { if (restuarantImage != null && restuarantImage.ContentLength > 0) { isValidDoc = formats.Any( p => restuarantImage.FileName.EndsWith(p, StringComparison.OrdinalIgnoreCase)); } if (isValidDoc) { restuarant.ImageUrl = Path.GetFileName(restuarantImage.FileName); } if (restuarant.Id == 0) { db.Restuarants.Add(restuarant); } else { db.Entry(restuarant).State = EntityState.Modified; } db.SaveChanges(); if (isValidDoc) { var fileDirectory = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["RestuarantImageUploadBase"]), restuarant.Id.ToString()); Directory.CreateDirectory(fileDirectory); var filePath = Path.Combine(fileDirectory, restuarant.ImageUrl); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } restuarantImage.SaveAs(filePath); } return(RedirectToAction("Index")); } return(View(restuarant)); }
public ActionResult AddRestuarant() { Restuarant model = new Restuarant(); return(View(model)); }
public ConsListing(Restuarant first, ILoR rest) { _first = first; _rest = rest; }