Exemple #1
0
        public ActionResult RegisterParticipant(string username)
        {
            string token  = (string)TempData["Token"];
            int    result = dBEntities.RegisterParticipant(token, username);

            if (result == 1)
            {
                Participant p = dBEntities.Participants.First(x => x.Token == token);
                Session["User"]       = p.Id;
                Session["Role"]       = "P";
                Session["Discussion"] = p.DiscussionID;
                @Discussion d = dBEntities.Discussions.Find(Session["Discussion"]);
                if (d.Status.Equals("Upcoming"))
                {
                    DateTime currentDateTime = DateTime.Now;
                    if (d.StartDateTime <= currentDateTime)
                    {
                        d.Status = "Active";
                        dBEntities.SaveChanges();
                    }
                }
                return(RedirectToAction("DiscussionRoom"));
            }
            else
            {
                return(RedirectToAction("ParticipantRegistration", new { token, error = "The username has been taken. Please try again." }));
            }
        }
Exemple #2
0
        public ActionResult ParticipantRegistration(string token, string error = null)
        {
            if (Session["Role"] != null && Session["Role"].Equals("M"))
            {
                return(RedirectToAction("DiscussionMessage"));
            }
            Participant p = dBEntities.Participants.First(x => x.Token == token);

            if (p.Username == null)
            {
                string name = p.Name;
                TempData["Token"] = token;
                ViewBag.Token     = token;
                ViewBag.Name      = name;
                ViewBag.Error     = error;
                return(View());
            }
            else
            {
                Session["User"]       = p.Id;
                Session["Role"]       = "P";
                Session["Discussion"] = p.DiscussionID;
                @Discussion d = dBEntities.Discussions.Find(Session["Discussion"]);
                if (d.Status.Equals("Upcoming"))
                {
                    DateTime currentDateTime = DateTime.Now;
                    if (d.StartDateTime <= currentDateTime)
                    {
                        d.Status = "Active";
                        dBEntities.SaveChanges();
                    }
                }
                return(RedirectToAction("DiscussionRoom"));
            }
        }