public IResturant ConvertJsonToResturant(dynamic json) { List <byte> imageBytes = new List <byte>(); foreach (var singlebyte in json.ResturantImage) { byte currentByte = JsonConvert.DeserializeObject <byte>(singlebyte); imageBytes.Add(currentByte); } List <ResturantReview> reviews = new List <ResturantReview>(); foreach (var review in json.ResturantReviews) { ResturantReview resReview = JsonConvert.DeserializeObject <ResturantReview>(review); reviews.Add(resReview); } IResturant resturant = new Resturant() { ResturantId = json.ResturantId, ResturantAddress = JsonConvert.DeserializeObject <FormalAddress>(json.FormalAddress), ResturantDescription = json.ResturantDescription, ResturantImage = imageBytes.ToArray(), ResturantName = json.ResturantName, ResturantOwnerName = json.ResturantOwnerName, ResturantReviews = reviews, ResturantStarRating = json.ResturantStarRating, ResturantType = Enum.Parse(typeof(ResturantType), json.ResturantType), DateAdded = DateTime.Parse(json.DateAdded) }; return(resturant); }
public ActionResult DeleteConfirmed(int id) { ResturantReview resturantReview = db.ResturantReviews.Find(id); db.ResturantReviews.Remove(resturantReview); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,Name,City,Country,Rating")] ResturantReview resturantReview) { if (ModelState.IsValid) { db.Entry(resturantReview).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resturantReview)); }
public ActionResult Create([Bind(Include = "id,Name,City,Country,Rating")] ResturantReview resturantReview) { if (ModelState.IsValid) { db.ResturantReviews.Add(resturantReview); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(resturantReview)); }
// GET: ResturantReviews/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ResturantReview resturantReview = db.ResturantReviews.Find(id); if (resturantReview == null) { return(HttpNotFound()); } return(View(resturantReview)); }