public ActionResult DeleteConfirmed(int id) { RestaurentData restaurentData = db.RestaurentDatas.Find(id); db.RestaurentDatas.Remove(restaurentData); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "RestaurentId,Name,Address,Zip,SearchDataId")] RestaurentData restaurentData) { if (ModelState.IsValid) { db.Entry(restaurentData).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SearchDataId = new SelectList(db.SearchDatas, "SearchDataId", "Name", restaurentData.SearchDataId); return(View(restaurentData)); }
// GET: RestaurentDatas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RestaurentData restaurentData = db.RestaurentDatas.Find(id); if (restaurentData == null) { return(HttpNotFound()); } return(View(restaurentData)); }
// GET: RestaurentDatas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RestaurentData restaurentData = db.RestaurentDatas.Find(id); if (restaurentData == null) { return(HttpNotFound()); } ViewBag.SearchDataId = new SelectList(db.SearchDatas, "SearchDataId", "Name", restaurentData.SearchDataId); return(View(restaurentData)); }
public JsonResult Save(string item, string location, List <Restaurant> searchResult) { if (searchResult == null || item.Trim() == "" || location.Trim() == "") { return(Json(new { success = false, responseText = "Data was NOT Saved. Restaurent Name, Location or Search data was empty." }, JsonRequestBehavior.AllowGet)); } try { SearchData searchData = new SearchData(); searchData.Name = item; searchData.Location = location; db.SearchDatas.Add(searchData); foreach (var restaurent in searchResult) { RestaurentData restaurentData = new RestaurentData(); restaurentData.Name = restaurent.Name; restaurentData.Address = restaurent.Address; restaurentData.Zipcode = restaurent.Zipcode; restaurentData.SearchDataId = searchData.SearchDataId; db.RestaurentDatas.Add(restaurentData); } if (db.SaveChanges() > 0) { return(Json(new { success = true, responseText = "Data Saved Successfully." }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, responseText = "Data was NOT Saved Successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw new Exception(ex.Message); } }