Beispiel #1
0
        // GET: Manager/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Manager manager = db.Managers
                              .AsNoTracking()
                              .Include(x => x.Emails)
                              .Include(x => x.GoalKeepers.Select(t => t.Team))
                              .Include(x => x.Players.Select(p => p.Player))
                              .Include(x => x.Image)
                              .Where(x => x.ManagerId == id)
                              .FirstOrDefault();

            if (User.IsInRole("User") && manager == null)
            {
                return(RedirectToAction("Index", "Manage"));
            }

            var             gameWeekId      = db.GameWeeks.AsNoTracking().Where(x => x.Complete).OrderByDescending(x => x.Number).Select(x => x.GameWeekId).FirstOrDefault();
            GameWeekSummary gameWeekSummary = gameWeekSerializer.DeSerialize(gameWeekId, "GameWeek");
            Form            form            = statisticsService.GetForm(id.Value, 40);

            ViewBag.AverageGoals    = statisticsService.GetAverageGoals(id.Value);
            ViewBag.AverageConceded = statisticsService.GetAverageConceded(id.Value);

            return(View(new ManagerProfile(manager, gameWeekSummary, form)));
        }
Beispiel #2
0
        public void Create(int gameWeekId)
        {
            var gameWeek = db.GameWeeks.Find(gameWeekId);
            var scores   = GetScores(gameWeekId);
            var table    = GetTable(gameWeekId);

            GameWeekSummary gameWeekSummary = new GameWeekSummary(gameWeek, scores, table);

            gameWeekSerializer.Serialize(gameWeekSummary, gameWeekId, "GameWeek");
        }
Beispiel #3
0
        public void Send(GameWeekSummary gameWeekSummary, ControllerContext context)
        {
            SmtpClient smtpClient = new SmtpClient();

            MailMessage message = new MailMessage();

            message.IsBodyHtml = true;
            message.Subject    = string.Format("Dream League Results - Game Week {0}", gameWeekSummary.GameWeek.Number);

            message.Body = RenderViewToString(context, "Email", gameWeekSummary);
            message.Body = PreMailer.Net.PreMailer.MoveCssInline(message.Body, false, stripIdAndClassAttributes: true).Html;

            var managers = db.Managers.AsNoTracking().Include(x => x.Emails);

            foreach (var manager in managers)
            {
                foreach (var email in manager.Emails)
                {
                    message.To.Add(email.Address);
                }
            }

            smtpClient.Send(message);
        }