public ActionResult DeleteConfirmed(int id) { Degem degem = db.Degems.Find(id); db.Degems.Remove(degem); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DegemId,DegemName,Color,BrandID,Quantity,VideoLink,ImagesLinks")] Degem degem) { if (ModelState.IsValid) { db.Entry(degem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BrandID = new SelectList(db.Brands, "id", "BrandName", degem.BrandID); return(View(degem)); }
public ActionResult Create([Bind(Include = "DegemId,DegemName,Color,BrandID,Quantity,VideoLink,ImageLink")] Degem degem) { if (ModelState.IsValid) { db.Degems.Add(degem); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BrandID = new SelectList(db.Brands, "id", "BrandName", degem.BrandID); return(View(degem)); }
// GET: Degems/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Degem degem = db.Degems.Find(id); if (degem == null) { return(HttpNotFound()); } return(View(degem)); }
// GET: Degems/Delete/5 public ActionResult Delete(int?id) { if (!User.IsInRole("Admin")) { return(new HttpUnauthorizedResult("Unauthorized")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Degem degem = db.Degems.Find(id); if (degem == null) { return(HttpNotFound()); } return(View(degem)); }
// GET: Degems/Search public ActionResult algo() { var bayesCLS = new BayesSimpleTextClassifier(); //Naive Bayes object https://github.com/afonsof/BayesSharp var degems = db.Degems.Include(d => d.Brand); // take list of all cars List <string> goodCar = db.TrainingDatas.Where(g => g.title.Equals("good")).Select(g => g.title).ToList(); //list of words for good car List <string> badCar = db.TrainingDatas.Where(g => g.title.Equals("bad")).Select(g => g.title).ToList(); //list of words for bad car foreach (var good in goodCar)// trains the good part { bayesCLS.Train("good", good); } foreach (var bad in badCar)// trains the bad part { bayesCLS.Train("bad", bad); } var maxScore = -1.0; //save the computed score var favoriteCar = new Degem(); //save the bast car foreach (var car in degems) // move on each car and check the score { //save the score var good = 0.0; var bad = 0.0; foreach (var p in car.Comments) // move on each post and check the score { var result = bayesCLS.Classify(p.ContentInfo); //:) if (result.ContainsKey("good")) { //check if have any result good += result["good"] / car.Comments.Count(); //if yes normelaize it and save it } if (result.ContainsKey("bad")) { bad += result["bad"] / car.Comments.Count(); } } if (good - bad > maxScore)//check the current car score { maxScore = good - bad; favoriteCar = car;//if is max save it } } return(View("Details", favoriteCar));//return the bast car }
// GET: Degems/Edit/5 public ActionResult Edit(int?id) { if (!User.IsInRole("Admin")) { return(new HttpUnauthorizedResult("Unauthorized")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Degem degem = db.Degems.Find(id); if (degem == null) { return(HttpNotFound()); } ViewBag.BrandID = new SelectList(db.Brands, "id", "BrandName", degem.BrandID); return(View(degem)); }