コード例 #1
0
        public ActionResult GetReport(int id)
        {
            string userId = User.Identity.GetUserId();

            bool reportSaved;

            if (userId != null)
            {
                reportSaved = _summaryService.CheckIfReportSaved(userId, id);
                if (reportSaved)
                {
                    ViewBag.Saved = "true";
                }
                else
                {
                    ViewBag.Saved = "false";
                }
            }
            else
            {
                ViewBag.Saved = "true";
            }


            StatSummaryVM ss = _summaryService.GetSummaryById(id);

            return(View("Report", ss));
        }
コード例 #2
0
        public IHttpActionResult SaveToReports(int id)
        {
            string userId = User.Identity.GetUserId();

            ApplicationUser user        = _context.Users.Include(u => u.StatSummaries).SingleOrDefault(u => u.Id == userId);
            StatSummaryVM   statSummary = _context.StatSummaryVMs.SingleOrDefault(ss => ss.Id == id);

            if (!_summaryService.CheckIfReportSaved(userId, statSummary.Id))
            {
                statSummary.ApplicationUsers.Add(user);
                user.StatSummaries.Add(statSummary);
                _context.SaveChanges();
            }

            return(Ok());
        }