Exemplo n.º 1
0
        public string ReportArticle(int articleID, ReportModel.reportType reportType, out bool isSucceed)
        {
            var reports = GetReports();
            int exists  = (from row in reports
                           where row.articleID == articleID &&
                           row.type == reportType
                           select row).Count();

            if (exists < 1)
            {
                int lastID;
                if (reports.Count > 0)
                {
                    lastID = reports.Max(x => x.ID);
                }
                else
                {
                    lastID = 0;
                }

                ReportModel newReport = new ReportModel();
                newReport.ID        = lastID + 1;
                newReport.articleID = articleID;
                newReport.type      = reportType;
                context.Reports.Add(newReport);
                context.SaveChanges();
                isSucceed = true;
                return("Article has been reported. Category: " + reportType + "");
            }
            else
            {
                isSucceed = false;
                return("Article has already been reported for category of " + reportType + "");
            }
        }
Exemplo n.º 2
0
        public ActionResult Report(int articleID, ReportModel.reportType reportType)
        {
            ReportAccess access = new ReportAccess();

            ViewData["ReportMessage"] = access.ReportArticle(articleID, reportType);

            return(View("ReportMessage"));
        }
        public ActionResult Report(int articleID, ReportModel.reportType reportType)
        {
            ReportAccess access = new ReportAccess();
            //ViewData["ReportMessage"] = access.ReportArticle(articleID, reportType);
            bool isSucceed;

            return(Read(articleID, access.ReportArticle(articleID, reportType, out isSucceed), isSucceed));
            //return View("ReportMessage");
        }