public ActionResult ForgotPassword(string EmailID) { //Verify Email ID //Generate Reset password link //Send Email string message = ""; bool status = false; using (OfficeEntities dc = new OfficeEntities()) { var account = dc.Users.Where(a => a.Email == EmailID).FirstOrDefault(); if (account != null) { //Send email for reset password string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword"); account.ResetPassword = resetCode; //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property //in our model class in part 1 dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "Reset password link has been sent to your email id."; } else { message = "Account not found"; } } ViewBag.Message = message; return(View()); }
public ActionResult Details(int id) { OfficeEntities oe = new OfficeEntities(); Employee model = oe.Employees.Single(emp => emp.Id == id); return(View(model)); }
public ActionResult ResetPassword(string id) { //Verify the reset password link //Find account associated with this link //redirect to reset password page if (string.IsNullOrWhiteSpace(id)) { return(HttpNotFound()); } using (OfficeEntities dc = new OfficeEntities()) { var user = dc.Users.Where(a => a.ResetPassword == id).FirstOrDefault(); if (user != null) { ResetPasswordModel model = new ResetPasswordModel(); model.ResetCode = id; return(View(model)); } else { return(HttpNotFound()); } } }
public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (OfficeEntities dc = new OfficeEntities()) { var user = dc.Users.Where(a => a.ResetPassword == model.ResetCode).FirstOrDefault(); if (user != null) { user.Password = Crypto.Hash(model.NewPassword); user.ResetPassword = ""; dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "New password updated successfully"; } } } else { message = "Something invalid"; } ViewBag.Message = message; return(View(model)); }
public ActionResult CreateEmployee(Employee employee) { //Employee employee = new Employee(); //employee.Name = formCollection["name"]; //employee.Age = int.Parse(string.IsNullOrEmpty(formCollection["age"]) ? "0" : formCollection["age"]); //employee.Gender = formCollection["gender"]; //employee.DepartmentId = int.Parse(string.IsNullOrEmpty(formCollection["departmentId"]) ? "0" : formCollection["departmentId"]); //employee.Designation = formCollection["designation"]; //employee.Address = formCollection["address"]; try { OfficeEntities oe = new OfficeEntities(); //oe.Employees.Add(employee); oe.Entry(employee).State = System.Data.Entity.EntityState.Added; oe.SaveChanges(); TempData["success"] = "Record inserted."; } catch (Exception ex) { Response.StatusCode = 500; TempData["success"] = "Something went wrong."; } return(RedirectToAction("Index")); }
//public ActionResult CreateEmployee() //{ // OfficeEntities oe = new OfficeEntities(); // ViewBag.departments = oe.Departments.ToList(); // return View(); //} //[HttpPost] //public ActionResult CreateEmployee(FormCollection fc) //{ // string name = fc["name"]; // int departmentId = int.Parse(fc["departmentId"]); // int age = int.Parse(fc["age"]); // string designation = fc["designation"]; // string address = fc["address"]; // string gender = fc["gender"]; // Employee emp = new Employee() // { // Name = name, // DepartmentId = departmentId, // Age = age, // Designation = designation, // Address = address, // Gender = gender // }; // OfficeEntities oe = new OfficeEntities(); // //oe.Employees.Add(emp); // oe.Entry(emp).State = System.Data.Entity.EntityState.Added; // oe.SaveChanges(); // TempData["msg"] = "Successfully added"; // return RedirectToAction("Index"); //} //public ActionResult EditEmployee(int id) //{ // OfficeEntities oe = new OfficeEntities(); // ViewBag.departments = oe.Departments.ToList(); // ViewBag.employee = oe.Employees.Single(emp => emp.Id == id); // return View(); //} //[HttpPost] //public ActionResult EditEmployee(FormCollection fc) //{ // int id = int.Parse(fc["id"]); // string name = fc["name"]; // int departmentId = int.Parse(fc["departmentId"]); // int age = int.Parse(fc["age"]); // string designation = string.IsNullOrEmpty(fc["designation"]) ? "" : fc["designation"]; // string address = fc["address"]; // string gender = fc["gender"]; // Employee emp = new Employee() // { // Id = id, // Name = name, // DepartmentId = departmentId, // Age = age, // Designation = designation, // Address = address, // Gender = gender // }; // OfficeEntities oe = new OfficeEntities(); // oe.Entry(emp).State = System.Data.Entity.EntityState.Modified; // oe.SaveChanges(); // TempData["msg"] = "Successfully updated"; // return RedirectToAction("Index"); //} #endregion public ActionResult CreateEmployee() { OfficeEntities oe = new OfficeEntities(); CreateEmployeeModel model = new CreateEmployeeModel(); model.departments = oe.Departments.ToList(); return(View(model)); }
public ActionResult Signup(User model) { using (var context = new OfficeEntities()) { context.User.Add(model); context.SaveChanges(); } return(RedirectToAction("Login")); }
public ActionResult EditEmployee(int id) { OfficeEntities oe = new OfficeEntities(); ViewBag.departments = oe.Departments.ToList(); Employee model = oe.Employees.Single(emp => emp.Id == id); return(View(model)); }
public ActionResult Register(User Acc) { using (var c = new OfficeEntities()) { c.Users.Add(Acc); c.SaveChanges(); } return(RedirectToAction("Login")); }
public ActionResult CreateEmployee() { OfficeEntities oe = new OfficeEntities(); ViewBag.departments = oe.Departments.ToList(); Employee employee = new Employee(); return(View(employee)); }
// GET: Employee public ActionResult Index() { OfficeEntities oe = new OfficeEntities(); var employees = oe.Employees.ToList(); ViewBag.msg = TempData["msg"]; return(View(employees)); }
// GET: Employee public ActionResult Index() { OfficeEntities oe = new OfficeEntities(); //ViewData["employees"] = oe.Employees.ToList(); //return View(); List <Employee> employees = oe.Employees.ToList(); return(View(employees)); }
public ActionResult EditEmployee(Employee model) { OfficeEntities oe = new OfficeEntities(); oe.Entry(model).State = System.Data.Entity.EntityState.Modified; oe.SaveChanges(); TempData["msg"] = "Successfully updated"; return(RedirectToAction("Index")); }
public ActionResult login(RegisterModel model) { using (var context = new OfficeEntities()) { bool isValid = context.Register.Any(x => x.UserName == model.UserName && x.Password == model.Password); if () } return View(); }
public ActionResult DeleteEmployee(int id) { OfficeEntities oe = new OfficeEntities(); Employee model = oe.Employees.Single(emp => emp.Id == id); oe.Entry(model).State = System.Data.Entity.EntityState.Deleted; oe.SaveChanges(); TempData["msg"] = "Successfully updated"; return(RedirectToAction("Index")); }
public ActionResult Login(Models.Membership model) { using (var context = new OfficeEntities()) { bool Isvalid = context.User.Any(a => a.UserName == model.UserName && a.Password == model.Password); if (Isvalid) { FormsAuthentication.SetAuthCookie(model.UserName, false); return(RedirectToAction("Index", "Employees")); } ModelState.AddModelError("", "Invalid username & password"); return(View()); } }
public ActionResult Login(User Acc) { using (var c = new OfficeEntities()) { bool isValid = c.Users.Any(a => a.UserName == Acc.UserName && a.Password == Acc.Password); if (isValid) { FormsAuthentication.SetAuthCookie(Acc.UserName, false); return(RedirectToAction("Index", "Employees")); } ModelState.AddModelError("", "Invalid user name and password "); return(View()); } }
public ActionResult Signup(Users model) { using (var context = new OfficeEntities()) { if (model.Username == null && model.Password == null) { return(View()); } else { context.Users.Add(model); context.SaveChanges(); } } return(RedirectToAction("login")); }
public ActionResult EditEmployee(int employee_id = 0) { Employee employee = new Employee(); if (employee_id != 0) { OfficeEntities oe = new OfficeEntities(); ViewBag.departments = oe.Departments.ToList(); if (oe.Employees.ToList().Exists(e => e.Id == employee_id)) { employee = oe.Employees.Where(e => e.Id == employee_id).Single(); } } Response.StatusCode = 404; return(View(employee)); }
public ActionResult EditEmployee(Employee employee) { //Employee employee = new Employee(); //employee.Name = formCollection["name"]; //employee.Age = int.Parse(string.IsNullOrEmpty(formCollection["age"]) ? "0" : formCollection["age"]); //employee.Gender = formCollection["gender"]; //employee.DepartmentId = int.Parse(string.IsNullOrEmpty(formCollection["departmentId"]) ? "0" : formCollection["departmentId"]); //employee.Designation = formCollection["designation"]; //employee.Address = formCollection["address"]; OfficeEntities oe = new OfficeEntities(); oe.Entry(employee).State = System.Data.Entity.EntityState.Modified; oe.SaveChanges(); TempData["success"] = "Record updated."; return(RedirectToAction("Index")); }
public ActionResult CreateEmployee(CreateEmployeeModel model) { OfficeEntities oe = new OfficeEntities(); if (model.employee.DepartmentId == null || model.employee.DepartmentId == 0) { ModelState.AddModelError("employee.DepartmentId", "Please select department"); } if (ModelState.IsValid) { oe.Entry(model.employee).State = System.Data.Entity.EntityState.Added; oe.SaveChanges(); TempData["msg"] = "Successfully added"; return(RedirectToAction("Index")); } model.departments = oe.Departments.ToList(); return(View(model)); }
public InfoAboutParticipant2(OfficeEntities OfficeEntities) { this.OfficeEntities = OfficeEntities; }