public ActionResult updateRating() { if (Request.Form["rate"] != null) { int id = Convert.ToInt32(Request.Form["restaurant"]); int givenRating = Convert.ToInt32(Request.Form["rateRest"]); int totalRating = restaurants.GetSingle(id).totalRating; int givenUser = restaurants.GetSingle(id).ratingGivenUser; totalRating += givenRating; givenUser += 1; double averageRate = totalRating / givenUser; Restaurant_info restInfo = new Restaurant_info(); restInfo.Id = id; restInfo.totalRating = totalRating; restInfo.ratingGivenUser = givenUser; restInfo.avarageRating = averageRate; restaurants.UpdateRating(restInfo); return(RedirectToAction("Index", new { Id = id })); } else { return(View("Index", "Home")); } }
public void Delete(int id) { Restaurant_info restInfo = this.context.Restaurant_info.SingleOrDefault(x => x.Id == id); this.context.Restaurant_info.Remove(restInfo); this.context.SaveChanges(); }
public void Update(Restaurant_info RestaurantInfo) { Restaurant_info restInfo = this.context.Restaurant_info.SingleOrDefault(x => x.Id == RestaurantInfo.Id); restInfo.restaurantName = RestaurantInfo.restaurantName; restInfo.ContactNumber = RestaurantInfo.ContactNumber; this.context.SaveChanges(); }
public void UpdateRating(Restaurant_info Restaurant_info) { Restaurant_info restInfo = this.context.Restaurant_info.SingleOrDefault(x => x.Id == Restaurant_info.Id); restInfo.totalRating = Restaurant_info.totalRating; restInfo.ratingGivenUser = Restaurant_info.ratingGivenUser; restInfo.avarageRating = Restaurant_info.avarageRating; this.context.SaveChanges(); }
public ActionResult AddRest(HttpPostedFileBase Picture) { if (Session["UserName"].ToString() == "admin") { if (Request.Form["restAddBtn"] != null) { if (Picture != null && Picture.ContentLength > 0) { Restaurant_info rest = new Restaurant_info(); var filename = Path.GetFileName(Picture.FileName); var path = Path.Combine(Server.MapPath("~/images"), filename); Picture.SaveAs(path); rest.restaurantName = Request.Form["restName"]; rest.restaurantDetails = Request.Form["detail"]; rest.ContactNumber = Request.Form["contactName"]; rest.restaurantLogo = "~/images/" + filename.ToString(); rest.Website = Request.Form["webName"]; restaurants.Insert(rest); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Admin")); } } else { return(RedirectToAction("Index", "Admin")); } } else { return(RedirectToAction("Index", "Home")); } }
public void UpdateRating(Restaurant_info Restaurant_info) { this.data.UpdateRating(Restaurant_info); }
public void Insert(Restaurant_info Restaurant_info) { this.data.Insert(Restaurant_info); }
public void Insert(Restaurant_info Restaurant_info) { this.context.Restaurant_info.Add(Restaurant_info); this.context.SaveChanges(); }