public ActionResult History()
        {
            var db = new HockeySignupsDb(_connectionString);
            IEnumerable <EventWithPeople> events = db.GetEventsWithCount();

            return(View(events));
        }
        public ActionResult History()
        {
            var db = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            IEnumerable <EventWithPeople> events = db.GetEventsWithCount();

            return(View(events));
        }
        public ActionResult History()
        {
            var db = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            IEnumerable <Event> events = db.GetEvents();
            //longer approach
            HistoryViewModel vm = new HistoryViewModel();

            //List<EventWithCount> eventsWithCounts = new List<EventWithCount>();
            //foreach (Event e in events)
            //{
            //    EventWithCount eventWithCount = new EventWithCount();
            //    eventWithCount.Event = e;
            //    eventWithCount.SignupCount = db.GetSignupCountForEvent(e.Id);
            //    eventsWithCounts.Add(eventWithCount);
            //}

            //vm.Events = eventsWithCounts;

            //shorter approach
            vm.Events = events.Select(e => new EventWithCount
            {
                Event       = e,
                SignupCount = db.GetSignupCountForEvent(e.Id)
            });


            return(View(vm));
        }
        public ActionResult CreateEvent(DateTime date, int maxPeople)
        {
            var   db = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            Event e  = new Event {
                Date = date, MaxPeople = maxPeople
            };

            db.AddEvent(e);
            TempData["Message"] = "Event Successfully created, Id: " + e.Id;
            return(RedirectToAction("Index", "Hockey"));
        }
Exemple #5
0
        public ActionResult NotificationSignup(string firstName, string lastName, string email)
        {
            var db = new HockeySignupsDb(_connectionString);
            var ns = new NotificationSignup
            {
                Email     = email,
                FirstName = firstName,
                LastName  = lastName
            };

            db.AddNotificationSignup(ns);
            return(View("NotificationSignupConfirmation"));
        }
        public ActionResult EventDetails(int id)
        {
            var   db = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            Event e  = db.GetEventById(id);
            IEnumerable <EventSignup> signups = db.GetEventSignups(id);
            var vm = new EventDetailsViewModel
            {
                Event   = e,
                Signups = signups
            };

            return(View(vm));
        }
Exemple #7
0
        public ActionResult NotificationSignup(string firstName, string lastName, string email)
        {
            var db = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            var ns = new NotificationSignup
            {
                Email     = email,
                FirstName = firstName,
                LastName  = lastName
            };

            db.AddNotificationSignup(ns);
            return(View("NotificationSignupConfirmation"));
        }
        public ActionResult EventDetails(int id)
        {
            var   db = new HockeySignupsDb(_connectionString);
            Event e  = db.GetEventById(id);
            IEnumerable <EventSignup> signups = db.GetEventSignups(id);
            var vm = new EventDetailsViewModel
            {
                Event   = e,
                Signups = signups
            };

            return(View(vm));
        }
Exemple #9
0
        static void Main(string[] args)
        {
            HockeySignupsDb db = new HockeySignupsDb(Settings1.Default.ConStr);

            //var e = new Event {Date = DateTime.Today.AddDays(3), MaxPeople = 20};
            //db.AddEvent(e);
            //Console.WriteLine(e.Id);
            db.GetEvents().ToList().ForEach(e =>
            {
                Console.WriteLine(e.Date + " " + e.MaxPeople + " " + e.Id);
            });
            Console.ReadKey(true);
        }
        public ActionResult CreateEvent(Event e)
        {
            HockeySignupsDb db = new HockeySignupsDb(_connectionString);

            db.AddEvent(e);
            #region TempData
            TempData["Message"] = "Event Successfully created, Id: " + e.Id;
            #endregion
            IEnumerable <NotificationSignup> signups = db.GetNotificationSignups();
            foreach (NotificationSignup signup in signups)
            {
                //send email using signup.Email
            }
            return(RedirectToAction("Index", "Hockey"));
        }
Exemple #11
0
        public ActionResult LatestEvent()
        {
            var   db                = new HockeySignupsDb(_connectionString);
            Event latestEvent       = db.GetLatestEvent();
            EventSignupViewModel vm = new EventSignupViewModel();

            vm.Event       = latestEvent;
            vm.EventStatus = db.GetEventStatus(latestEvent);
            vm.Signup      = new EventSignup();
            if (Request.Cookies["firstName"] != null)
            {
                vm.Signup.FirstName = Request.Cookies["firstName"].Value;
                vm.Signup.LastName  = Request.Cookies["lastName"].Value;
                vm.Signup.Email     = Request.Cookies["email"].Value;
            }
            return(View(vm));
        }
Exemple #12
0
        public ActionResult CreateEvent(DateTime date, int maxPeople)
        {
            var   db = new HockeySignupsDb(_connectionString);
            Event e  = new Event {
                Date = date, MaxPeople = maxPeople
            };

            db.AddEvent(e);
            TempData["Message"] = "Event Successfully created, Id: " + e.Id;
            IEnumerable <NotificationSignup> signups = db.GetNotificationSignups();

            foreach (NotificationSignup signup in signups)
            {
                //send email using signup.Email
            }
            return(RedirectToAction("Index", "Hockey"));
        }
        public ActionResult CreateEvent(DateTime date, int maxPeople)
        {
            var   db = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            Event e  = new Event {
                Date = date, MaxPeople = maxPeople
            };

            db.AddEvent(e);

            TempData["Message"] = "Event Successfully created, Id: " + e.Id;
            IEnumerable <NotificationSignup> signups = db.GetNotificationSignups();

            foreach (NotificationSignup signup in signups)
            {
                SendNotificationEmail(signup);
            }
            return(RedirectToAction("Index", "Hockey"));
        }
Exemple #14
0
        public ActionResult EventSignup(string firstName, string lastName, string email, int eventId)
        {
            HockeySignupsDb db     = new HockeySignupsDb(_connectionString);
            Event           e      = db.GetEventById(eventId);
            EventStatus     status = db.GetEventStatus(e);

            if (status == EventStatus.InThePast)
            {
                #region TempData
                TempData["Error"] = "You cannot sign up to a game in the past. Jerk.";
                #endregion
                return(RedirectToAction("Index"));
            }
            if (status == EventStatus.Full)
            {
                #region TempData
                TempData["Error"] = "Nice try sucker....";
                #endregion
                return(RedirectToAction("Index"));
            }
            EventSignup s = new EventSignup
            {
                Email     = email,
                FirstName = firstName,
                LastName  = lastName,
                EventId   = eventId
            };

            HttpCookie firstNameCookie = new HttpCookie("firstName", s.FirstName);
            HttpCookie lastNameCookie  = new HttpCookie("lastName", s.LastName);
            HttpCookie emailCookie     = new HttpCookie("email", s.Email);

            Response.Cookies.Add(firstNameCookie);
            Response.Cookies.Add(lastNameCookie);
            Response.Cookies.Add(emailCookie);

            db.AddEventSignup(s);
            #region TempData
            TempData["Message"] =
                "You have succesfully signed up for this weeks game, looking forward to checking you into the boards!";
            #endregion

            return(RedirectToAction("Index"));
        }
Exemple #15
0
        public ActionResult EventSignup(string firstName, string lastName, string email, int eventId)
        {
            var db     = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            var e      = db.GetEventById(eventId);
            var status = db.GetEventStatus(e);

            if (status == EventStatus.InThePast)
            {
                TempData["Error"] = "You cannot sign up to a game in the past!!";
                return(RedirectToAction("Index"));
            }
            if (status == EventStatus.Full)
            {
                TempData["Error"] = "Nice try!";
                return(RedirectToAction("Index"));
            }
            EventSignup s = new EventSignup
            {
                Email     = email,
                FirstName = firstName,
                LastName  = lastName,
                EventId   = eventId
            };

            HttpCookie firstNameCookie = new HttpCookie("firstName", s.FirstName);
            HttpCookie lastNameCookie  = new HttpCookie("lastName", s.LastName);
            HttpCookie emailCookie     = new HttpCookie("email", s.Email);

            Response.Cookies.Add(firstNameCookie);
            Response.Cookies.Add(lastNameCookie);
            Response.Cookies.Add(emailCookie);

            db.AddEventSignup(s);

            TempData["Message"] =
                "You have successfully signed up for this weeks game, looking forward to checking you into the boards!";
            return(RedirectToAction("Index"));
        }