Пример #1
0
        //[HttpPost]
        //public JsonResult GetByPosition()
        //{
        //    try
        //    {
        //        var id = (Guid)Membership.GetUser().ProviderUserKey;
        //        var staff = StaffManager.GetById(id);
        //        var items = StaffManager.GetByPosition(staff.StaffPosition.sDescription);

        //        return Json(new { Result = "OK", Options = items.Select(m => new { DisplayText = m.sStaffName, Value = m.kStaffId }) });
        //    }
        //    catch (Exception ex)
        //    {
        //        return Json(new { Result = "ERROR", Message = ex.Message });
        //    }
        //}

        public JsonResult GetById(Guid Id)
        {
            try
            {
                var itemFounds = StaffUserManager.GetUser(Id);
                return(Json(new
                {
                    Result = "OK",
                    Records = itemFounds.Select(m => new { Username = m.Username, Password = m.Password, Role = m.Roles.FirstOrDefault().RoleName })
                }
                            , JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
        public ActionResult UserPassword(ApplicationHeaderViewModel model)
        {
            if (ModelState.IsValid)
            {
                bool changePasswordSucceeded;

                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);

                    changePasswordSucceeded = currentUser.ChangePassword(model.User.OldPassword, model.User.NewPassword);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                    ModelState.AddModelError("", "failed.");
                }

                if (changePasswordSucceeded)
                {
                    return(RedirectToAction("LogOff", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }
            else
            {
                ModelState.AddModelError("", "failed.");
            }

            Guid id    = (Guid)Membership.GetUser().ProviderUserKey;
            var  users = StaffUserManager.GetUser(id);

            if (users != null)
            {
                model.User = new UserProfileChangePasswordModel
                {
                    UserName    = users[0].Username,
                    OldPassword = users[0].Password
                };
            }
            return(View(model));
        }
        public ActionResult UserPassword()
        {
            ViewBag.Setting = "first active";

            BookingRepairViewModel model = new BookingRepairViewModel();

            Guid id = (Guid)Membership.GetUser().ProviderUserKey;

            var users = StaffUserManager.GetUser(id);

            if (users != null)
            {
                model.User = new UserProfileChangePasswordModel
                {
                    UserName = users[0].Username
                };
            }

            return(View(model));
        }
        public ActionResult UserProfile()
        {
            ViewBag.Settinguser = "******";

            ApplicationHeaderViewModel model = new ApplicationHeaderViewModel();

            Guid id = (Guid)Membership.GetUser().ProviderUserKey;

            model.Staff = StaffManager.GetById(id);
            var users = StaffUserManager.GetUser(id);

            if (users != null)
            {
                model.User = new UserProfileChangePasswordModel
                {
                    UserName    = users[0].Username,
                    OldPassword = users[0].Password
                };
            }

            return(View(model));
        }
 public StaffUserService()
 {
     _staffUserManager = new StaffUserManager();
 }