public ActionResult Register() { var res = _UseradminService.GetCustomerList(); if (TempData["EditUserId"] != null) { Login_tbl Login_tbl = _UseradminService.EditUser(Convert.ToInt32(TempData["EditUserId"])); return(View("Register", new RegistrationVM { ID = Login_tbl.ID, FirstName = Login_tbl.FirstName, LastName = Login_tbl.LastName, Email = Login_tbl.UserName, Password = UrlSecurityManager.Decrypt(Login_tbl.Password, ConfigurationManager.AppSettings["SecurityKey"]), ConfirmPassword = UrlSecurityManager.Decrypt(Login_tbl.Password, ConfigurationManager.AppSettings["SecurityKey"]), MobileNo = Login_tbl.MobileNo, CustomerId = Login_tbl.CustomerId, CustomerList = res })); } else { return(View("Register", new RegistrationVM { CustomerList = res })); } }
public IHttpActionResult PutLogin_tbl(int id, Login_tbl login_tbl) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} if (id != login_tbl.l_id) { return(BadRequest()); } db.Entry(login_tbl).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Login_tblExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetLogin_tbl(int id) { Login_tbl login_tbl = db.Login_tbl.Find(id); if (login_tbl == null) { return(NotFound()); } return(Ok(login_tbl)); }
public IHttpActionResult PostLogin_tbl(Login_tbl login_tbl) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} db.Login_tbl.Add(login_tbl); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = login_tbl.l_id }, login_tbl)); }
public IHttpActionResult DeleteLogin_tbl(int id) { Login_tbl login_tbl = db.Login_tbl.Find(id); if (login_tbl == null) { return(NotFound()); } db.Login_tbl.Remove(login_tbl); db.SaveChanges(); return(Ok(login_tbl)); }
//connectionstring = ConfigurationManager.ConnectionStrings["IPSU_DEV_V5"].ConnectionString; public Login_tbl UserLogin(Login_tbl login_Tbl) { using (var context = new UniversityEntities()) { var t = context.Login_tbl.Where(y => y.UserName == login_Tbl.UserName && y.Password == login_Tbl.Password && y.IsDeleted != true).FirstOrDefault(); return(t); } //string consql = "data source=DESKTOP-M1MKH53\\SQLEXPRESS;initial catalog=IPSU_DEV_V5;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"; //DataTable dt = new DataTable(); //SqlDataAdapter da = new SqlDataAdapter(); //int usercount; //try //{ // SqlConnection ConnectionString = new SqlConnection(consql); // using (ConnectionString) // { // ConnectionString.Open(); // SqlCommand cmd = new SqlCommand("sp_LoginUniersity", ConnectionString); // cmd.CommandType = CommandType.StoredProcedure; // cmd.Parameters.AddWithValue("@UserName", web_Login.UserName); // cmd.Parameters.AddWithValue("@Password", web_Login.Password); // // cmd.Parameters.AddWithValue("@RollName",web_Login.RoleName); // using (da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.StoredProcedure; // da.Fill(dt); // } // usercount = Convert.ToInt32(dt.Rows[0]["AuthenticationValue"]); // ConnectionString.Close(); // if (usercount == 1) // { // return true; // } // else // { // ConnectionString.Close(); // return false; // } // } // // return true; //} //catch (Exception e) //{ // return false; //} }
public ActionResult ChangePassword(string id) { Login_tbl Login_tbl = _loginService.CheckEmail(id, UrlSecurityManager.Decrypt); if (Login_tbl == null) { TempData["Success"] = "False"; TempData["Message"] = "Your link has Expired"; return(RedirectToAction("Login")); } else { Session["UnEncryptedEmail"] = Login_tbl.UserName; return(View()); } }
public bool ChangePassword(string Email, string Password) { try { using (var context = new UniversityEntities()) { Login_tbl Login_tbl = context.Login_tbl.Where(y => y.UserName.Equals(Email) && y.IsDeleted != true).FirstOrDefault(); Login_tbl.Password = Password; context.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
public ActionResult Login(Login_tbl obj) { List <Login_tbl> li = new List <Login_tbl>(); if (obj.Username != null && obj.Password != null) { if (BLL.LoginClass.userlogin(obj.Username, obj.Password)) { Session["Users"] = obj.Name; var query = (from data in db.Login_tbl where data.Username == obj.Username select new { data.Name, data.Username, data.role }); foreach (var d in query) { Session["Users"] = d.Username.ToUpper(); Session["Name"] = d.Name; Session["role"] = d.role; } // TempData["Loggeduser"] = username; // TempData["Startname"] = DateTime.Now.ToString(); ViewBag.n = "Login Successfull..."; return(RedirectToAction("Index", "Stories")); // return PartialView(); } else { ViewBag.n = "Invalid Username or Password..."; return(View()); } } else { ViewBag.n = "Required All Feilds..."; return(View()); } }
public ActionResult Login(Login_tbl login_Tbl) { login_Tbl.Password = UrlSecurityManager.Encrypt(login_Tbl.Password, ConfigurationManager.AppSettings["SecurityKey"]); var Result = _loginService.UserLogin(login_Tbl); if (Result == null) { //TempData["Success"] = "False"; //TempData["Message"] = "You are not a valid user...Please Register..!!"; ViewBag.Message = "You are not a valid user...Please Register..!!"; return(View()); } else if (Result.RoleID == 4) { FormsAuthentication.SetAuthCookie(Result.UserName, false); Session["AdminLoginID"] = Result.ID; Session["RoleID"] = Result.RoleID; Session["AdminName"] = Result.FirstName + " " + Result.LastName; var res = _UseradminService.GetUserList().ToList(); var viewModel = AutoMapper.Mapper.Map <List <Login_tbl>, List <Login_tbl> >(res); Session["UserList"] = viewModel; // Session["UserLoginID"] = viewModel; return(RedirectToAction("Index", "Home")); } else if (Result.RoleID == 5) { FormsAuthentication.SetAuthCookie(Result.UserName, false); Session["UserLoginID"] = Result.ID; Session["RoleID"] = Result.RoleID; Session["UserNamee"] = Result.FirstName + " " + Result.LastName; return(RedirectToAction("Index", "Home")); } else { ViewBag.Message = "You are not a valid user...Please Register..!!"; return(View()); } // return View(); }
public ActionResult Login(Login_tbl model) { if (ModelState.IsValid) { int?userId = _account.ValidateLogin(model); if (userId != null) { var userDetail = _account.GetUserDetail(Convert.ToInt32(userId)); //FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); // Setting userId and User name in session after successful login _session.UserId = userDetail.UserID; _session.UserName = userDetail.Name; _session.isAdmin = userDetail.isAdmin; if (userDetail.isAdmin) { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Products", "Home")); } } else { ModelState.AddModelError(string.Empty, "Invalid Username or password"); return(View()); } } else { ModelState.AddModelError(string.Empty, "Username and password is required!!"); } return(View(model)); }
public (bool, bool) RegisterUser(Login_tbl Login_tbl) { try { using (var context = new UniversityEntities()) { if (context.Login_tbl.Any(x => x.UserName.Equals(Login_tbl.UserName) && x.IsDeleted == false)) { return(false, true); } else { context.Login_tbl.Add(Login_tbl); context.SaveChanges(); return(true, false); } } } catch (Exception e) { return(false, false); } }
public ActionResult ForgotPassword(string Email) { Login_tbl Login_tbl = _loginService.ForgotPassword(Email); if (Login_tbl != null) { var EmailInfo = _loginService.AddEmailInfo(Login_tbl.ID); var smtp = new SmtpClient { Host = ConfigurationManager.AppSettings["Host"], Port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]), EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(ConfigurationManager.AppSettings["AdminId"], ConfigurationManager.AppSettings["AdminPassword"]) }; using (var message = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["AdminId"], "Admin"), new MailAddress(Email, "user")) { Subject = "Reset Password", Body = "Hello " + Login_tbl.FirstName + ",<br/><br/>Welcome to Online Training Portal. We received a request to reset your password.Please <a href=" + ConfigurationManager.AppSettings["ChangePasswordUrl"] + "/" + UrlSecurityManager.Encrypt(EmailInfo.ID.ToString(), ConfigurationManager.AppSettings["SecurityKey"]) + ">Click Here</a> to reset Password<br/><br/>This link is only valid for 30 minutes. <br/><br/><br/>Regards,<br/>Admin" }) { message.IsBodyHtml = true; smtp.Send(message); } TempData["Success"] = "True"; TempData["Message"] = "please check your email to change password"; return(RedirectToAction("Login")); } else { TempData["Success"] = "False"; TempData["Message"] = "Email does not exist.Please contact Admin for registration"; return(RedirectToAction("Login")); } }
public (bool, bool) SaveEditUserDetails(Login_tbl Login_tbl) { try { using (var context = new UniversityEntities()) { Login_tbl Logintbl = context.Login_tbl.FirstOrDefault(x => x.ID == Login_tbl.ID); Logintbl.FirstName = Login_tbl.FirstName; Logintbl.LastName = Login_tbl.LastName; Logintbl.MobileNo = Login_tbl.MobileNo; Logintbl.UserName = Login_tbl.UserName; Logintbl.Password = Login_tbl.Password; Logintbl.CustomerId = Login_tbl.CustomerId; Logintbl.RoleID = Login_tbl.RoleID; Logintbl.CreatedDate = Login_tbl.CreatedDate; Logintbl.CreatedBy = Login_tbl.CreatedBy; Logintbl.IsDeleted = Login_tbl.IsDeleted; Logintbl.AdminId = Login_tbl.AdminId; context.SaveChanges(); return(true, false); //if (context.Login_tbl.Any(x => x.UserName.Equals(Login_tbl.UserName) && x.IsDeleted == false)) //{ // return (false, true); //} //else //{ // context.Login_tbl.Add(Login_tbl); // return (true, false); //} } } catch (Exception e) { return(false, false); } }
public ActionResult Login() { Login_tbl model = new Login_tbl(); return(View(model)); }
public Login_tbl UserLogin(Login_tbl login_Tbl) { var result = _LoginRepository.UserLogin(login_Tbl); return(result); }
public (bool, bool) SaveEditUserDetails(Login_tbl Login_tbl) { return(_UseradminRepository.SaveEditUserDetails(Login_tbl)); }
public (bool, bool) RegisterUser(Login_tbl Login_tbl) { return(_UseradminRepository.RegisterUser(Login_tbl)); }
public Login_tbl GetLogin_Tbl(string u_name, string p_word) { Login_tbl lo = db.Login_tbl.Where(x => x.u_name == u_name && x.p_word == p_word).FirstOrDefault(); return(lo); }