// GET: Account
 public ActionResult Index()
 {
     using (OurDbContext db = new OurDbContext())
     {
         return RedirectToAction("index", "Home");
     }
 }
        public ActionResult Register(UAccount account)
        {

            if(ModelState.IsValid)
            {
                using (OurDbContext db = new OurDbContext())
                {

                    db.uAccount.Add(account);
                    db.SaveChanges();
                }
                ModelState.Clear();
                ViewBag.Message = account.Username + " sucessfully registered!";
            }
            return View();
        }
        public ActionResult Login(UAccount user)
        {

            using (OurDbContext db = new OurDbContext())
            {
                var usr = db.uAccount.Where(u => u.Username == user.Username && u.Password == user.Password).FirstOrDefault();
                if (usr != null)
                {
                    Session["UserId"] = usr.UserID.ToString();
                    Session["Username"] = usr.Username.ToString();
                    return RedirectToAction("LoggedIn");
                }
                else {

                    ModelState.AddModelError("","Wrong usernae or password");
                }
            }
            return View();
        }