Ejemplo n.º 1
0
 public ActionResult Index()
 {
     using (DanceDbContext db = new DanceDbContext())
     {
         return(View(db.Dancers.ToList()));
     }
 }
Ejemplo n.º 2
0
 public ActionResult Register(Dancers account)
 {
     if (ModelState.IsValid)
     {
         using (DanceDbContext db = new DanceDbContext())
         {
             db.Dancers.Add(account);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = account.Name + "successfuly registered";
     }
     return(View());
 }
Ejemplo n.º 3
0
        public ActionResult Login(Dancers usrAccount)
        {
            using (DanceDbContext db = new DanceDbContext())
            {
                var usr = db.Dancers.Where(u => u.Id == usrAccount.Id && u.Password == usrAccount.Password);
                if (usr != null)
                {
                    Online.Add(usrAccount.Email.ToString());
                    Session["UserID"]   = usrAccount.Id.ToString();
                    Session["UserMail"] = usrAccount.Email.ToString();
                    return(RedirectToAction("LoggedIn"));
                }
                else
                {
                    ModelState.AddModelError("", "Mail or Password is wrong.");
                }
            }

            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult Login(Dancers user)
        {
            using (DanceDbContext db = new DanceDbContext())
            {
                try
                {
                    var usr = db.Dancers.Single(u => u.Email == user.Email && u.Password == user.Password);

                    if (usr != null)
                    {
                        Session["Id"]    = usr.Id.ToString();
                        Session["Email"] = usr.Email.ToString();
                        return(RedirectToAction("LoggedIn"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Email or password is wrong");
                    }
                }
                catch (System.InvalidOperationException e) { Console.WriteLine("Email or password is wrong"); }
            }
            OnLineUsers.Add(user.Email);
            return(View());
        }