public ActionResult UserLogin(VMUserLogin userData) { if (ModelState.IsValid) { string localPassword = helper.HashValue(userData.PasswordValue); var data = dbReference.Users.FirstOrDefault(m => m.Email == userData.EmailId && m.Password.Equals(localPassword)); if (data != null) { FormsAuthentication.SetAuthCookie(userData.EmailId, false); return(Json(new { success = true, }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, }, JsonRequestBehavior.AllowGet)); } return(View()); }
public string Create(VMUser userDetails) { //if (dbReference.Users.Where(m => m.Email == userDetails.Email).SingleOrDefault()== null) if (dbReference.Users.SingleOrDefault(m => m.Email == userDetails.Email) == null) { if (userDetails.ImageUpload != null) { string filename = Path.GetFileName(userDetails.ImageUpload.FileName); filePath = Path.Combine("\\Images\\ProfileImages\\", _customHelper.HashValue(filename.ToString() + DateTime.Now) + Path.GetExtension(filename)); title = _customHelper.HashValue(filename.ToString() + DateTime.Now) + Path.GetExtension(filename); string directoryPath = Path.Combine(HttpContext.Current.Server.MapPath("~/Images/ProfileImages"), title); userDetails.ImageUpload.SaveAs(directoryPath); } else { filePath = "\\Images\\ProfileImages\\default.png"; title = "default.png"; } var _user = new User() { Email = userDetails.Email, Name = userDetails.Name, Password = _customHelper.HashValue(userDetails.Password), Mobile = userDetails.Mobile, CreationTime = DateTime.Now, ImageUrl = filePath, DateOfBirth = DateTime.Now, Rank = 0 }; dbReference.Users.Add(_user); dbReference.SaveChanges(); return(userDetails.Email); } return(null); }