public ActionResult ChangePassword(ChangePassword cp)
 {
     CustomMembershipProvider cmp = new CustomMembershipProvider();
     if (string.IsNullOrEmpty(cp.ChangeUserPwd.OtherUser) && string.IsNullOrEmpty(cp.ChangeUserPwd.NewPassword))
     {
         cp.AdminUsername = "******";
         cmp.ChangePassword(cp.AdminUsername, cp.OldPassword, cp.NewPassword);
     }
     if (!string.IsNullOrEmpty(cp.ChangeUserPwd.OtherUser) && !string.IsNullOrEmpty(cp.ChangeUserPwd.NewPassword)) {
         if (cp.ChangeUserPwd.OtherUser.ToLower() != "jesper")
         {
             cmp.UpdateUser(cp.ChangeUserPwd.OtherUser, cp.ChangeUserPwd.NewPassword, "");
         }
     }
     return RedirectToAction("Index","Home");
 }
 public AccountController()
 {
     _membership = new CustomMembershipProvider();
 }
        public ActionResult CreateEvent(vm_EventUser vm)
        {
            vm.Event.ID = Guid.NewGuid();
            foreach (var eq in Event.InitialQuestion)
            {
                var question = new EventQuestion { ID = Guid.NewGuid(), Question = eq, EventID = vm.Event.ID, Date = vm.Event.Date };
                _eventQuestionRepo.Save(question);
            }
            vm.Event.Company = vm.Username.ToLower();
            vm.Event.Description = vm.Event.Description;
            CustomMembershipProvider cmp = new CustomMembershipProvider();
            var status = new MembershipCreateStatus();

            if (!string.IsNullOrEmpty(vm.Password))
            {
                User user = _userRepository.FindAll(u => u.UserName == vm.Username.ToLower()).FirstOrDefault();
                if (user != null)
                {
                    cmp.UpdateUser(vm.Username, vm.Password, vm.Email);
                }
                else {
                    cmp.CreateUser(vm.Username.ToLower(), vm.Password, vm.Email, "", "", true, null, out status);
                    User newUser = _userRepository.FindAll(u => u.UserName == vm.Username.ToLower()).FirstOrDefault();
                    newUser.UserEmailAddress = vm.Email;
                    newUser.Event.Add(vm.Event);
                    _userRepository.Save(newUser);
                }
            }
            else
            {
                _eventRepo.Save(vm.Event);
            }
            return RedirectToAction("SingleEvent", "Event", new {vm.Event.ID });
        }