public ActionResult Register(UserModelcs user) { if (ModelState.IsValid) { //try { var crypto = new SimpleCrypto.PBKDF2(); var encrypt = crypto.Compute(user.Password); var sysuser = DB.LoginTBLs.Create(); sysuser.UserID = Guid.NewGuid(); sysuser.Email = user.Email; sysuser.Password = encrypt; sysuser.Password = crypto.Salt; sysuser.UserType = UserModelcs.UserTypes.User.ToString(); DB.LoginTBLs.Add(sysuser); //var profile = DB.ProfileTBLs.Create(); //profile.Created = DateTime.Now; //profile.IsActive = true; //DB.ProfileTBLs.Add(profile); DB.SaveChanges(); //} //catch (DbEntityValidationException dbEx) //{ // foreach (var validationErrors in dbEx.EntityValidationErrors) // { // foreach (var validationError in validationErrors.ValidationErrors) // { // Trace.TraceInformation("Property: {0} Error: {1}", // validationError.PropertyName, // validationError.ErrorMessage); // } // } //} //int ID = (from i in DB.ProfileTBLs select i.ProfileID).Last(); //string querystr = "UPDATE LoginTBL SET ProfileID=@ID WHERE [email protected]"; //DB.ProfileTBLs.SqlQuery(querystr); //DB.SaveChanges(); return RedirectToAction("Index", "Home"); } return View(user); }
public ActionResult Login(UserModelcs user) { if (ModelState.IsValid) { if (IsValid(user.Email, user.Password)) { FormsAuthentication.SetAuthCookie(user.Email, false); { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "Login Data is incorrect."); } } return View(user); }