public ActionResult Login(UserLogin ul) { UserDetailsBEL objUserBEL = new UserDetailsBEL(); if (ModelState.IsValid) { if (ul.UserName.Contains('@')) { objUserBEL.Email_Id = ul.UserName; } else { objUserBEL.Phone_No1 = ul.UserName; } objUserBEL.Password = Secure.Encrypt(ul.Password); UserDetailsDAL objUserDAL = new UserDetailsDAL(); //UserDetailsBEL tr = UserLoginDetailsViewModel vm = new UserLoginDetailsViewModel(objUserDAL.FunAuthenticateUser(objUserBEL)); //UserLoginDetailsViewModel vm = new UserLoginDetailsViewModel(objUserDAL.CheckPhoneNoExists(objUserBEL.Phone_No1)); if (vm.ErrorMessage == string.Empty) { FormsAuthentication.SetAuthCookie(objUserBEL.User_ID, true); Session["userDetail"] = vm; Session["userPhoneNo/Email"] = !string.IsNullOrWhiteSpace(vm.Phone_No1)? vm.Phone_No1: vm.Email_Id; string tempdata; if (TempData["RequestedUrl"] != null) { tempdata = Convert.ToString(TempData["RequestedUrl"]); TempData["RequestedUrl"] = null; //need to modify later return(Redirect("http://localhost/" + tempdata)); // return RedirectToAction(tempdata, "parkingArea"); } else { return(RedirectToAction("Index", "UserDashbaord")); } } else { ModelState.AddModelError("", vm.ErrorMessage.ToString()); } } else { ModelState.AddModelError("", "Login data is incorrect!"); } return(View()); }
public UserLoginDetailsViewModel(UserDetailsBEL newObj) { UserDetailObj = newObj; User_ID = newObj.User_ID; User_Name = newObj.User_Name; Phone_No1 = newObj.Phone_No1; Email_Id = newObj.Email_Id; Last_Login = newObj.Last_Login; Alternate_Email_Id = newObj.Alternate_Email_Id; FullName = newObj.First_Name + " " + newObj.Last_Name; ErrorMessage = newObj.ErrorMessage; }
public ActionResult SignUp(SignupViewModel vm) { UserDetailsBEL objUserBEL = new UserDetailsBEL(); objUserBEL.Email_Id = vm.EmailId; objUserBEL.Password = Secure.Encrypt(vm.Password); objUserBEL.First_Name = vm.FirstName; objUserBEL.Last_Name = vm.LastName; objUserBEL.Phone_No1 = vm.Mobile; UserDetailsDAL objUserDAL = new UserDetailsDAL(); List <string> OTPList = new List <string>(); if (ModelState.IsValid) { UserLoginDetailsViewModel LDvm = new UserLoginDetailsViewModel(objUserDAL.AddUserDetails(objUserBEL)); if (string.IsNullOrEmpty(LDvm.ErrorMessage) && (LDvm.User_ID != "" || LDvm.User_ID != string.Empty)) { //FormsAuthentication.SetAuthCookie(objUserBEL.User_ID, true); Session["userDetail"] = LDvm; // return RedirectToAction("Index", "UserDashbaord"); OTPBEL OTPBel = new OTPBEL(); OTPList = OTPBel.GetAndSendOTP(Convert.ToInt64(objUserBEL.Phone_No1)); if (OTPList != null) { if (Convert.ToBoolean(OTPList[2])) { // Session[OTPList[2]+"_OTP"] = OTPList[0]; Session["OTP"] = OTPList[0]; } } return(RedirectToAction("VerifyOTP", "OTP")); // return RedirectToAction("Login", "TrueWheelsUser"); } else { ModelState.AddModelError("", LDvm.ErrorMessage.ToString()); } } else { // Response.Write(ModelState.SelectMany(x => x.Value.Errors.Select(z => z.Exception))); ModelState.AddModelError("", "Data is incorrect!"); } return(View()); }
public bool SignUpWithFB(string FirstName, string LastName, string EmailId, string Fb_id) { UserDetailsBEL objUserBEL = new UserDetailsBEL(); objUserBEL.Email_Id = EmailId; objUserBEL.Password = FirstName + "@Truewheels"; objUserBEL.First_Name = FirstName; objUserBEL.Last_Name = LastName; objUserBEL.SignUp_Mode_ID = "FB"; objUserBEL.Phone_No1 = "NA"; objUserBEL.Other_ID = Fb_id; UserDetailsDAL objUserDAL = new UserDetailsDAL(); UserLoginDetailsViewModel LDvm = new UserLoginDetailsViewModel(objUserDAL.AddUserDetails(objUserBEL)); if (string.IsNullOrEmpty(objUserBEL.ErrorMessage) && (objUserBEL.User_ID != "" || objUserBEL.User_ID != string.Empty)) { //FormsAuthentication.SetAuthCookie(objUserBEL.User_ID, true); Session["userDetail"] = LDvm; return(true); // return RedirectToAction("Index", "UserDashbaord"); } else { return(false); ModelState.AddModelError("", objUserBEL.ErrorMessage.ToString()); } //UserDetailsBEL tr = objUserDAL.AddUserDetails(objUserBEL); //if (tr.ErrorMessage == "") //{ // //FormsAuthentication.SetAuthCookie(objUserBEL.User_ID, true); // return true; // //return RedirectToAction("Index", "UserDashbaord"); //} //else //{ // return false; // ModelState.AddModelError("", tr.ErrorMessage.ToString()); //} // return View(); }
public HttpResponseMessage GetAllPosts() { var res = new HttpResponseMessage(); JObject jContent = new JObject(); string json = string.Empty; try { UserDetailsBEL objUserBEL = new UserDetailsBEL(); UserDetailsDAL objUserDAL = new UserDetailsDAL(); json = JsonConvert.SerializeObject(objUserDAL.GetAllPosts()); if (!string.IsNullOrEmpty(json)) { res.StatusCode = HttpStatusCode.Accepted; var jsonArray = JArray.Parse(json); //jContent = JObject.Parse(json); jContent = new JObject(new JProperty("Success", true), new JProperty("result", jsonArray)); // return Json(locations, JsonRequestBehavior.AllowGet); } } catch (Exception ex) { res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", ex.Message), new JProperty("ErrorMessage", ex.InnerException.ToString()), new JProperty("UserId", null)))); } //return Request.CreateResponse<string>(HttpStatusCode.OK, mystring); res.Content = new StringContent(jContent.ToString()); return(res); }
public ActionResult ChangePassword(UpdateCred UP) { UserDetailsBEL objUserBEL = new UserDetailsBEL(); if (Session["ForgotMobleNum"] != null) { objUserBEL.Phone_No1 = Convert.ToString(Session["ForgotMobleNum"]); Session["ForgotMobleNum"] = null; objUserBEL.Password = Secure.Encrypt(UP.Password); UserDetailsDAL objUserDAL = new UserDetailsDAL(); Transaction tr = objUserDAL.UpdateCred(objUserBEL); if (tr.Success == true) { return(RedirectToAction("Login", "TrueWheelsUser")); //return RedirectToAction("Index", "UserDashbaord"); } else { ModelState.AddModelError("", tr.Success.ToString()); } } return(View("Index", "ForgotPassword")); }
public HttpResponseMessage Signup(SignupViewModel vm) { var res = new HttpResponseMessage(); JObject jContent = new JObject(); Random ran = new Random(); if (vm != null) { vm.Password = Secure.Encrypt(vm.Password);// Secure.Encrypt("TWuser@" + Convert.ToString(ran.Next(1000, 9999))); vm.ConfirmPassword = Secure.Encrypt(vm.Password); if (ModelState.IsValid) { try { UserDetailsBEL objUserBEL = new UserDetailsBEL(); objUserBEL.Email_Id = vm.EmailId; objUserBEL.Password = vm.Password; objUserBEL.First_Name = vm.FirstName; objUserBEL.Last_Name = vm.LastName; objUserBEL.Phone_No1 = vm.Mobile; UserDetailsDAL objUserDAL = new UserDetailsDAL(); UserLoginDetailsViewModel ulvm = new UserLoginDetailsViewModel(objUserDAL.AddUserDetails(objUserBEL)); if (ulvm.User_ID != "0") { res.StatusCode = HttpStatusCode.Created; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", true), new JProperty("Message", "User added successfully"), new JProperty("Transation", ulvm.User_ID)))); } else { res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", ulvm.ErrorMessage), new JProperty("ErrorMessage", ulvm.ErrorMessage), new JProperty("Transation", ulvm.User_ID)))); } } catch (Exception ex) { res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", ex.Message), new JProperty("ErrorMessage", ex.InnerException.ToString()), new JProperty("Transation", null)))); } } else { var errorList = (from item in ModelState where item.Value.Errors.Any() select item.Value.Errors[0].ErrorMessage).ToList(); res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", "Invalid Input"), new JProperty("ErrorMessage", errorList), new JProperty("Transation", null)))); } } res.Content = new StringContent(jContent.ToString()); return(res); }
public HttpResponseMessage Login(UserLogin vm) { var res = new HttpResponseMessage(); JObject jContent; if (ModelState.IsValid) { try { UserDetailsBEL objUserBEL = new UserDetailsBEL(); objUserBEL.Email_Id = vm.Email; objUserBEL.Password = vm.Password; objUserBEL.Phone_No1 = vm.Mobile; objUserBEL.User_Name = vm.UserName; UserDetailsDAL objUserDAL = new UserDetailsDAL(); UserLoginDetailsViewModel lvm = new UserLoginDetailsViewModel(objUserDAL.FunAuthenticateUser(objUserBEL)); if (lvm.User_ID != "0") { res.StatusCode = HttpStatusCode.Accepted; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", true), new JProperty("Email", lvm.Email_Id), new JProperty("Mobile", lvm.Phone_No1), new JProperty("Username", lvm.User_Name), new JProperty("LastLogin", lvm.Last_Login), new JProperty("UserId", lvm.User_ID)))); } else { res.StatusCode = HttpStatusCode.Unauthorized; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", lvm.ErrorMessage), new JProperty("ErrorMessage", lvm.ErrorMessage), new JProperty("UserId", lvm.User_ID)))); } } catch (Exception ex) { res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", ex.Message), new JProperty("ErrorMessage", ex.InnerException.ToString()), new JProperty("UserId", null)))); } //return Request.CreateResponse<string>(HttpStatusCode.OK, mystring); } else { var errorList = (from item in ModelState where item.Value.Errors.Any() select item.Value.Errors[0].ErrorMessage).ToList(); res.StatusCode = HttpStatusCode.BadRequest; jContent = new JObject( new JProperty("result", new JObject( new JProperty("Success", false), new JProperty("Message", "Invalid Input"), new JProperty("ErrorMessage", errorList), new JProperty("Transation", null)))); } res.Content = new StringContent(jContent.ToString()); return(res); }