/*
        // GET: Reports
        public ActionResult Index()
        {
            if (!IsTeamAdmin())
            {
                return new HttpStatusCodeResult(403);
            }

            return View(db.TeamReports.ToList());
        }

        // GET: Reports/Details/5
        public ActionResult Details(Guid? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            TeamReport teamReport = db.TeamReports.Find(id);
            if (teamReport == null)
            {
                return HttpNotFound();
            }
            return View(teamReport);
        }*/

        // GET: Reports/Create
        public ActionResult Create()
        {
            if (!IsTeamAdmin())
            {
                return new HttpStatusCodeResult(403);
            }

            var round = new TeamReportRound();
            if (!round.Enabled)
            {
                TempData["Alert"] = string.Format("现在不在上传时间之内,【{2}】的允许上传时间时间为{0}-{1}", round.StartTime, round.EndTime, round.Name);
                return RedirectToAction("Index", "Manage");
            }

            if (Extensions.GetContextUser(ref db).TeamRecord.Team.ReportUpdated == true)
            {
                TempData["Alert"] = string.Format("【{0}】你已经上传过团队报告!", round.Name);
                return RedirectToAction("Index", "Manage");
            }

            return View();
        }
        public ActionResult NewReportRound(TeamReportRound round)
        {
            if (ModelState.IsValid)
            {
                if (round.StartTime >= round.EndTime || round.EndTime <= DateTime.Now)
                {
                    TempData["Alert"] = "请检查时间输入是否有误!";
                    return View(round);
                }
                var appSettings = new AppSettings();
                appSettings.ReportRoundName = round.Name;
                appSettings.ReportStartTime = round.StartTime;
                appSettings.ReportEndTime = round.EndTime;

                foreach (var team in db.Teams)
                {
                    team.ReportUpdated = false;
                }
                db.SaveChanges();
                TempData["Alert"] = string.Format("新建场次【{0}】成功,允许上传时间为{1}-{2}!", round.Name, round.StartTime, round.EndTime);
                return RedirectToAction("Reports");
            }

            return View(round);
        }