Exemple #1
0
        //Register
        public ActionResult Register(UserAccount account)
        {
            if (ModelState.IsValid)
            {
                using (OurDbContex db = new OurDbContex())
                {
                    db.userAccount.Add(account);
                    db.SaveChanges();

                    ModelState.Clear();
                    ViewBag.Message = account.FirstName + " " + account.LastName + " konto zostało zarejestrowane";
                }
            }
            return(View());
        }
Exemple #2
0
 public ActionResult Login(UserAccount user)
 {
     using (OurDbContex db = new OurDbContex())
     {
         var usr = db.userAccount.Where(u => u.Username == user.Username && u.Password == user.Password).FirstOrDefault();
         if (usr != null)
         {
             Session["UserId"]   = usr.UserId.ToString();
             Session["Username"] = usr.Username.ToString();
             Session["Hobby"]    = usr.Hobby.ToString();
             Session["Location"] = usr.Location.ToString();
             Session["Numer"]    = usr.Numer.ToString();
             Session["Describe"] = usr.Describe.ToString();
             return(RedirectToAction("LoggedIn"));
         }
         else
         {
             ModelState.AddModelError("", "Nieprawidłowe hasło lub login");
         }
     }
     return(View());
 }