Example #1
0
        public ActionResult ReportSpam(ReportSpamViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Session["Username"] != null)
                {
                    string        username         = Session["Username"] as string;
                    Spam          spam             = new Spam(model, username);
                    SuccessAndMsg addNewSpamResult = spamDAO.AddNewSpam(spam);
                    if (!addNewSpamResult.IsSuccess)
                    {
                        // thêm báo cáo vi phạm thất bại, chuyển đến trang lỗi
                        TempData["Error"] = new ErrorViewModel(addNewSpamResult.Message);
                        return(RedirectToAction("SharedError", "Error"));
                    }
                    else
                    {
                        ViewBag.AddNewSpamMsg = addNewSpamResult.Message;
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", ActionMessage.MissingOrInvalidInfo);
            }

            return(View(model));
        }
Example #2
0
        /// <summary>
        /// GET: /User/ReportSpam
        /// Báo cáo vi phạm
        /// </summary>
        /// <param name="productID">Mã sản phẩm</param>
        /// <returns></returns>
        public ActionResult ReportSpam(int productID)
        {
            ReportSpamViewModel model = new ReportSpamViewModel();

            model.ProductID = productID;

            return(View(model));
        }
Example #3
0
        public Spam(ReportSpamViewModel model, string reporter)
        {
            this.Reporter   = reporter;
            this.ReportDate = DateTime.Now;
            this.Resolved   = false;
            this.ProductID  = model.ProductID;

            if (model != null)
            {
                this.SpamContent  = model.SpamContent;
                this.Resolver     = null;
                this.ResolveDate  = null;
                this.ProperReport = null;
            }
        }