Beispiel #1
0
 public ActionResult Signup(User objNewUser)
 {
     try
     {
         using (var context = new ISD_DemoEntities2())
         {
             var chkUser = (from s in context.Users where s.UserName == objNewUser.UserName || s.EmailId == objNewUser.EmailId select s).FirstOrDefault();
             if (chkUser == null)
             {
                 var keyNew   = EncryptionHelper.GeneratePassword(10);
                 var password = EncryptionHelper.EncodePassword(objNewUser.Password, keyNew);
                 objNewUser.Password   = password;
                 objNewUser.CreateDate = DateTime.Now;
                 objNewUser.ModifyDate = DateTime.Now;
                 objNewUser.VCode      = keyNew;
                 context.Users.Add(objNewUser);
                 context.SaveChanges();
                 ModelState.Clear();
                 return(RedirectToAction("LogIn", "Home"));
             }
             ViewBag.ErrorMessage = "User Allredy Exixts!!!!!!!!!!";
             return(View());
         }
     }
     catch (Exception e)
     {
         ViewBag.ErrorMessage = "Some exception occured" + e;
         return(View());
     }
 }
Beispiel #2
0
 public ActionResult LogIn(string userName, string password)
 {
     try
     {
         using (var context = new ISD_DemoEntities2())
         {
             var getUser = (from s in context.Users where s.UserName == userName || s.EmailId == userName select s).FirstOrDefault();
             if (getUser != null)
             {
                 var hashCode = getUser.VCode;
                 //Password Hasing Process Call Helper Class Method
                 var encodingPasswordString = EncryptionHelper.EncodePassword(password, hashCode);
                 //Check Login Detail User Name Or Password
                 var query = (from s in context.Users where (s.UserName == userName || s.EmailId == userName) && s.Password.Equals(encodingPasswordString) select s).FirstOrDefault();
                 if (query != null)
                 {
                     //RedirectToAction("Details/" + id.ToString(), "FullTimeEmployees");
                     //return View("../Admin/Registration"); url not change in browser
                     return(RedirectToAction("Index", "Home"));
                 }
                 ViewBag.ErrorMessage = "Invallid User Name or Password";
                 return(View());
             }
             ViewBag.ErrorMessage = "Invallid User Name or Password";
             return(View());
         }
     }
     catch (Exception e)
     {
         ViewBag.ErrorMessage = " Error!!! contact [email protected]";
         return(View());
     }
 }