Beispiel #1
0
        public ActionResult Register(string firstName, string lastName, string password, string confirmpassword)
        {
            UserAccount user = new UserAccount();

            user.FirstName       = firstName;
            user.LastName        = lastName;
            user.Password        = password;
            user.ConfirmPassword = confirmpassword;
            user.UserName        = user.FirstName.ToLower().ToString() + '.' + user.LastName.ToLower().ToString();
            if (ModelState.IsValid)
            {
                using (AracTakipDBOEntities db = new AracTakipDBOEntities())
                {
                    if (db.UserAccount.Any(x => x.UserName == user.UserName))
                    {
                        ViewBag.DublicateMessage = "User Name already exists.";
                    }
                    else
                    {
                        db.UserAccount.Add(user);
                        db.SaveChanges();
                    }
                }
                ModelState.Clear();
                ViewBag.Message = user.FirstName + " " + user.LastName + " succesfully created.";
            }
            return(View());
        }
Beispiel #2
0
 // GET: Account
 public ActionResult Index()
 {
     using (AracTakipDBOEntities db = new AracTakipDBOEntities())
     {
         return(View(db.UserAccount.ToList()));
     }
 }
Beispiel #3
0
 public ActionResult Login(UserAccount user)
 {
     using (AracTakipDBOEntities db = new AracTakipDBOEntities())
     {
         var usr = db.UserAccount.FirstOrDefault(x => x.UserName == user.UserName && x.Password == user.Password);
         if (usr != null)
         {
             Session["UserID"]   = usr.UserID.ToString();
             Session["UserName"] = usr.UserName.ToString();
             return(RedirectToAction("Create", "Devices"));
         }
         else
         {
             ModelState.AddModelError("", "UserName or Password is wrong.");
         }
     }
     return(View());
 }