예제 #1
0
        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());
        }
예제 #2
0
        public ActionResult Details(int id)
        {
            OfficeEntities oe    = new OfficeEntities();
            Employee       model = oe.Employees.Single(emp => emp.Id == id);

            return(View(model));
        }
예제 #3
0
        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());
                }
            }
        }
예제 #4
0
        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));
        }
예제 #5
0
        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"));
        }
예제 #6
0
        //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"));
 }
예제 #8
0
        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));
        }
예제 #9
0
        public ActionResult Register(User Acc)
        {
            using (var c = new OfficeEntities())
            {
                c.Users.Add(Acc);
                c.SaveChanges();
            }

            return(RedirectToAction("Login"));
        }
예제 #10
0
        public ActionResult CreateEmployee()
        {
            OfficeEntities oe = new OfficeEntities();

            ViewBag.departments = oe.Departments.ToList();

            Employee employee = new Employee();

            return(View(employee));
        }
예제 #11
0
        // GET: Employee
        public ActionResult Index()
        {
            OfficeEntities oe = new OfficeEntities();

            var employees = oe.Employees.ToList();

            ViewBag.msg = TempData["msg"];

            return(View(employees));
        }
예제 #12
0
        // 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));
        }
예제 #13
0
        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"));
        }
예제 #14
0
        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();
        }
예제 #15
0
        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());
     }
 }
예제 #17
0
 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"));
 }
예제 #19
0
        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));
        }
예제 #20
0
        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"));
        }
예제 #21
0
        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;
 }