Beispiel #1
0
 // ДОПИСАТЬ
 public void AddUser(BllRole bllRole, BllUser bllUser)
 {
     DalRole dalRole = roleRepository.GetById(bllRole.Id);
     //??????????????????????????????????????????????????
     roleRepository.AddUser(dalRole, bllUser.ToDal());
     uow.Commit();
 }
Beispiel #2
0
 public void AddRole(BllUser bllUser, BllRole bllRole)
 {
     DalUser dalUser = userRepository.GetById(bllUser.Id);
     //??????????????????????????????????????????????????
     userRepository.AddRole(dalUser, bllRole.ToDal());
     uow.Commit();
 }
        public MembershipUser CreateUser(string login, string password)
        {
            MembershipUser membershipUser = GetUser(login, false);

            if (membershipUser != null) return null;

            var user = new BllUser()
            {
                Login = login,
                Password = Crypto.HashPassword(password)
            };

            var role = RoleService.GetAll().FirstOrDefault(r => r.Name == "Пользователь");
            if (role != null)
            {
                user.Roles.Add(role);
            }

            UserServise.Create(user);
            membershipUser = GetUser(login, false);
            return membershipUser;
        }
Beispiel #4
0
 public ActionResult DeleteConfirmed(BllUser user)
 {
     service.Delete(user);
     return RedirectToAction("Index");
 }
        public ActionResult DeleteConfirmed(BllUser user)
        {
            try
            {
                userService.Delete(user);
            }
            catch (ArgumentNullException e)
            {
                return RedirectToAction("Index", "Error", new { id = "Параметр " + e.Message + " NULL" });
            }
            catch
            {
                return RedirectToAction("Index", "Error", new { id = "Ошибка при сохранении файла в БД" });
            }

            return RedirectToAction("Index", "User");
        }
 private MembershipUser ToMembershipUser(BllUser user)
 {
     return new MembershipUser("CustomMembershipProvider", user.Email, null, user.Email, null, null, false, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue);
 }
Beispiel #7
0
 public BllUser Update(BllUser bllUser)
 {
     DalUser oldUser = userRepository.Update(bllUser.ToDalUser());
     uow.Commit();
     return oldUser == null ? null : oldUser.ToBll();
 }
Beispiel #8
0
 public void RemoveRole(BllUser bllUser, BllRole bllRole)
 {
     DalUser dalUser = userRepository.GetById(bllUser.Id);
     userRepository.RemoveRole(dalUser, bllRole.ToDal());
     uow.Commit();
 }
Beispiel #9
0
 public IEnumerable<BllRole> GetRoles(BllUser bllUser)
 {
     return userRepository.GetRoles(bllUser.ToDal()).Select(r => r.ToBll());
 }
Beispiel #10
0
 public void Delete(BllUser bllUser)
 {
     userRepository.Delete(bllUser.ToDalUser());
     uow.Commit();
 }
Beispiel #11
0
 public BllUser Create(BllUser bllUser)
 {
     BllUser newUser = userRepository.Create(bllUser.ToDalUser()).ToBll();
     uow.Commit();
     return newUser;
 }