public async Task <IHttpActionResult> Putrating(int id, rating rating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rating.ratingID) { return(BadRequest()); } db.Entry(rating).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ratingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public seat(bool headrest, rating rating, material material, int belt) { mHeadrest = headrest; mRating = rating; mMaterial = material; mBelt = belt; }
public HttpResponseMessage PutUserRating_for_project([FromBody] rating r) { var rating = TriaCulturaRepository.putRating(r); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, rating); return(response); }
public ActionResult AddRateAjax(int rate, string message) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://127.0.0.1:18080"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); rating r = new rating(); r.rate = rate; r.comment = message; int id = 1; var response = client.PostAsJsonAsync <rating>("Epione_JEE-web/epione/rate/add/" + id, r).Result; if (response.StatusCode == HttpStatusCode.OK) { ViewBag.result = response.Content.ReadAsAsync <rating>().Result; } else { ViewBag.result = "error"; } return(View()); }
public static string ConvertToStr(rating rate) { if (rate == rating.D) { return("D"); } else if (rate == rating.C) { return("C"); } else if (rate == rating.B) { return("B"); } else if (rate == rating.A) { return("A"); } else { return(""); } }
public ActionResult DeleteConfirmed(int id) { rating rating = db.ratings.Find(id); db.ratings.Remove(rating); db.SaveChanges(); return(RedirectToAction("Index")); }
public void comprobarId(long id) { foreach (rating r in adminService.getComentarios()) { if (id.Equals(r.id)) { rating = r; } } }
public ActionResult Edit([Bind(Include = "ratingID,rate,overview,datumRatinga,datumIstekaRatinga")] rating rating) { if (ModelState.IsValid) { db.Entry(rating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rating)); }
public ActionResult Edit([Bind(Include = "id,productId,userRate,comment,ratePic,userEmail,replied,rateDate")] rating rating) { if (ModelState.IsValid) { db.Entry(rating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rating)); }
public async Task <IHttpActionResult> Getrating(int id) { rating rating = await db.ratings.FindAsync(id); if (rating == null) { return(NotFound()); } return(Ok(rating)); }
public ActionResult Create([Bind(Include = "ratingID,rate,overview,datumRatinga,datumIstekaRatinga")] rating rating) { if (ModelState.IsValid) { db.Ratinzi.Add(rating); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rating)); }
public JsonResult UpdateRating(int id, string score, string type) { string msg = ""; string result = "0"; string bars = ""; int like = 0, dislike = 0; if (Session["userinfo"] == null) { msg = "Üye olmalısın"; } else { int userid = (int)Session["userid"]; if (OK.RatingScore(id, type, userid) != 0) { result = "0"; msg = "Daha önce oyladın"; } else { rating rating = new rating(); rating.UserId = userid; rating.ItemId = id; rating.Score = score; rating.Type = type; rating.ActionDate = DateTime.Now; Db.rating.Add(rating); Db.SaveChanges(); OK.AddPost(userid, "" + id + "", (score == "+1" ? "like" : "dislike") + "-" + type, true); OK.UpdateRating(userid, +5); var rate = Db.rating.Where(x => x.ItemId == id && x.Type == type); like = rate.Where(x => x.Score == "+1").Count(); dislike = rate.Where(x => x.Score == "-1").Count(); int xlike = like + dislike == 0 ? 50 : 100 * like / (like + dislike); int xdislike = like + dislike == 0 ? 50 : 100 - (100 * like / (like + dislike)); if (type == "topic") { var topic = Db.topic.Find(id); topic.Rating = like + "/" + dislike; } else if (type == "comment") { var comment = Db.comment.Find(id); comment.Rating = like + "/" + dislike; } Db.SaveChanges(); result = score == "+1" ? "Bunu beğendin" : "Bunu beğenmedin"; bars = "<div class=\"like\" title=\"" + xlike + "%\" style=\"width: " + 180 * xlike / 100 + "px;\"></div><div class=\"dislike\" title=\"" + xdislike + "%\" style=\"width: " + 180 * xdislike / 100 + "px;\"></div>"; msg = "Başarıyla oyladın"; } } return(Json(new { msg = msg, result = result, bars = bars, like = like, dislike = dislike }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "id,series_id,user_id,value,comment")] rating rating) { if (ModelState.IsValid) { db.Entry(rating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.series_id = new SelectList(db.series, "id", "title", rating.series_id); ViewBag.user_id = new SelectList(db.user, "id", "name", rating.user_id); return(View(rating)); }
public void Rate(int id) { rating Rating = new rating { rate = Convert.ToInt32(Convert.ToDouble(Request.QueryString["rate"]) * 2), employee_id = id, created_at = DateTime.Now }; ES.Add(Rating); ES.Commit(); }
public async Task <IHttpActionResult> Postrating(rating rating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ratings.Add(rating); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = rating.ratingID }, rating)); }
// GET: ratings/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } rating rating = db.ratings.Find(id); if (rating == null) { return(HttpNotFound()); } return(View(rating)); }
public async Task <IHttpActionResult> Deleterating(int id) { rating rating = await db.ratings.FindAsync(id); if (rating == null) { return(NotFound()); } db.ratings.Remove(rating); await db.SaveChangesAsync(); return(Ok(rating)); }
public ActionResult CreateRating(rating rating) { try { ES.Add(rating); ES.Commit(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { rating rating = ES.GetById(id); ES.Delete(rating); ES.Commit(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: ratings/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } rating rating = db.rating.Find(id); if (rating == null) { return(HttpNotFound()); } ViewBag.series_id = new SelectList(db.series, "id", "title", rating.series_id); ViewBag.user_id = new SelectList(db.user, "id", "name", rating.user_id); return(View(rating)); }
public void InsertNew([FromQuery] int stars, [FromQuery] string head, [FromQuery] string body) { /// read the file /// parse - list of json object /// string filePath = @"C:\Users\Oren\Desktop\FinalProject\finalProject_service\finalProject_service\RestaurantRating.txt"; List <rating> _data = new List <rating>(); /// add the new object (rating) rating temp = new rating(stars, head, body); _data.Add(temp); // _data should be the list from the file string json = JsonConvert.SerializeObject(_data.ToArray()); /// save the new list to file System.IO.File.WriteAllText(filePath, json); }
public void openWindow() { this.workingKey = ""; this.workingMod = new Wrestler.modifier( this.stmod1, this.stmod2, ref this.starr); rating[] newRats1 = new rating[main.genericAttributes.Length]; rating[] newRats2 = new rating[main.genericAttributes.Length]; for (int i = 0; i < newRats1.Length; i++) { newRats1[i] = rating.D; newRats2[i] = rating.D; } this.workingMod.minAtt = newRats1 ; this.workingMod.maxAtt = newRats2; this.populateMenus(); this.ShowDialog(); }
public ActionResult deleteRate(rating rate) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://127.0.0.1:18080"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.DeleteAsync("Epione_JEE-web/epione/rate/" + rate.id).Result; if (response.StatusCode == HttpStatusCode.OK) { ViewBag.result = response.Content.ReadAsAsync <rating>().Result; } else { ViewBag.result = "error"; } return(View()); }
public ActionResult Rate(rating r) { try { if (ModelState.IsValid) { r.users_id = user.Get(User.Identity.Name).id; r.datetime = DateTime.Now; rating.Rate(r); Flash.Set(TempData, "Rated! 🍾"); return(Redirect("/Detail?id=" + r.items_id)); } item i = item.Get(r.items_id); ViewBag.Ratings = rating.Get(r.items_id); ViewBag.id = r.items_id; ViewBag.Rating = r; Flash.Set(TempData, "You forgot to fill in something 😧"); return(View("Index", i)); } catch { Flash.Set(TempData, "Something went wrong 😕"); return(Redirect("/Detail?id=" + r.items_id)); } }
void setRating(rating rating) { mRating = rating; }
// Constructors public bodypart(rating in_beauty = rating.D) { __damage = rating.D; __beauty = in_beauty; }
partial void Insertrating(rating instance);
partial void Updaterating(rating instance);
partial void Deleterating(rating instance);
public ActionResult Create([Bind(Include = "id,productId,userRate,comment,ratePic,userEmail,replied,rateDate")] rating rating, HttpPostedFileBase ratePicture) { var user = User.Identity.GetUserName(); if (User == null) { return(RedirectToAction("Index", "Main")); } if (rating.userRate == 0) { ViewBag.prodId = rating.productId; ViewBag.prodName = db.Products.FirstOrDefault(a => a.productId == rating.productId).productName; ViewBag.error = "Select Rating"; return(View(rating)); } rating.userEmail = user; var product = db.Products.FirstOrDefault(a => a.productId == rating.productId); var rate = db.ratings.Where(a => a.productId == rating.productId).ToList(); if (product == null) { return(RedirectToAction("Index", "Home")); } int perc = 0; //it start with 1 because we including the current rate int numRatings = 1; //it start with users current rate because we including the current rate to get the total rates int totalRatings = rating.userRate; if (rate.Count > 0 && product.numRatings > 0) { foreach (var r in rate) { totalRatings += r.userRate; } numRatings += product.numRatings; double max = numRatings * 5; double percent = ((totalRatings / max) * 100); perc = Convert.ToInt32(percent); } else { double max = numRatings * 5; double percent = ((totalRatings / max) * 100); perc = Convert.ToInt32(percent); } if (ratePicture != null) { rating.ratePic = uploader.getFileByte(ratePicture); } if (ModelState.IsValid) { product.numRatings = numRatings; product.perc = perc; rating.rateDate = DateTime.Now; db.ratings.Add(rating); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(rating)); }