Ejemplo n.º 1
0
        public ActionResult Edit(EmployeeViewModel employee)
        {
            if (ModelState.IsValid)
            {
                var m            = _employeesProvider.GetEmployee(employee.Id);
                var currenCourse = m.Course;
                var course       = _coursesProvider.GetCourse(employee.Course);

                if (m.Keeper == true && currenCourse.Id != course.Id)
                {
                    ModelState.AddModelError("CannotChangeCourse", "Nie można zmienić wydziału/kursu pracownika który jest opiekunem kierunku");
                }
                else
                {
                    m.Course        = course;
                    m.Administrator = employee.Administrator;
                    m.FirstName     = employee.FirstName;
                    m.LastName      = employee.LastName;
                    m.Moderator     = employee.Moderator;

                    _employeeUpdater.Update(m);

                    return(Json(true));
                }
            }

            return(PartialView("Partials/_FormSubmitResult", ModelState));
        }
Ejemplo n.º 2
0
        public ActionResult UpdateProfile(UpdateProfileViewModel profile)
        {
            if (ModelState.IsValid)
            {
                var user     = _authenticationService.MembershipService.GetUserProfileByKey(profile.UserId);
                var employee = _employeesProvider.GetEmployee(profile.UserId);
                employee.Email = profile.Email;

                _authenticationService.MembershipService.UpdateUser(profile.UserName, profile.Email, true);
                _employeeUpdater.Update(employee);

                if (profile.IsLockedOut == false && user.Membership.IsLockedOut == true)
                {
                    _authenticationService.MembershipService.UnLockUser(user.UserName, DateTime.Now);
                }
                else if (profile.IsLockedOut == true && user.Membership.IsLockedOut == false)
                {
                    _authenticationService.MembershipService.LockOutUser(user.UserName, DateTime.Now);
                }
            }

            return(RedirectToAction("Manage", new { userId = profile.UserId }));
        }