public ActionResult UpdateCategory(TblCategory tbl)
 {
     if (ModelState.IsValid)
     {
         _context.TblCategory.Update(tbl);
         _context.SaveChanges();
         return(RedirectToAction("Category"));
     }
     return(View("Category"));
 }
Beispiel #2
0
        public IActionResult Ratings(int productId, ModelInput input)
        {
            MLContext    mlContext  = new MLContext();
            ITransformer mlModel    = mlContext.Model.Load(@"..\WebApplication9ML.Model\MLModel.zip", out var modelInputSchema);
            var          predEngine = mlContext.Model.CreatePredictionEngine <ModelInput, ModelOutput>(mlModel);

            input.Year = DateTime.Now.Year;
            ModelOutput result = predEngine.Predict(input);

            // tbl.MemberId = 1;
            //tbl.ProductId = 1;
            ViewBag.result = result;

            //tbl.Rating = Convert.ToInt32(result.Score);
            TblCustomerRatings x = new TblCustomerRatings();

            x.MemberId  = Convert.ToInt32(HttpContext.Session.GetString("id"));
            x.ProductId = Convert.ToInt32(TempData["id"]);
            x.Comment   = input.Comment;
            x.Rating    = System.Math.Abs(Convert.ToInt32(result.Score));
            _context.TblCustomerRatings.Add(x);
            _context.SaveChanges();
            List <TblCustomerRatings> m = _context.TblCustomerRatings.Where(i => i.ProductId == Convert.ToInt32(TempData["id"])).ToList();

            ViewBag.Comments = m;
            productId        = Convert.ToInt32(TempData["id"]);
            return(RedirectToAction("Ratings", new { productId }));
        }
        public ActionResult Register(TblMembers user)
        {
            if (ModelState.IsValid)
            {
                _context.TblMembers.Add(user);
                _context.SaveChanges();

                ModelState.Clear();
                ViewBag.Message = user.FirstName + " " + user.LastName + " is successfully registered.";
            }
            return(View());
        }