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)); }
/// <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)); }
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; } }