Exemplo n.º 1
0
        public ActionResult Create()
        {
            var user  = new BllUserEntity();
            var roles = _roleService.GetAll().ToList();

            ViewBag.Roles = new SelectList(roles, "Id", "Name");
            return(PartialView("Create", user));
        }
Exemplo n.º 2
0
 public ActionResult Edit(BllUserEntity itemUser, int role)
 {
     if (itemUser != null)
     {
         itemUser.BllRole = _roleService.GetById(role);
         _userService.Update(itemUser);
     }
     return(RedirectToAction("Control"));
 }
Exemplo n.º 3
0
        public override bool IsUserInRole(string username, string roleName)
        {
            BllUserEntity user = UserService.Contains(username);

            if (user != null && user.BllRole.Name == roleName)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public bool Update(BllUserEntity item)
        {
            var user = _userRepository.GetById(item.Id);

            if (user == null)
            {
                return(false);
            }
            _userRepository.Update(item.ToDal());
            _unitOfWork.Commit();
            return(true);
        }
Exemplo n.º 5
0
 public ActionResult Create(BllUserEntity itemUser, int role)
 {
     itemUser.BllRole = _roleService.GetById(role);
     if (itemUser.Name == null || itemUser.Password == null)
     {
         return(View("Error"));
     }
     if (_userService.Contains(itemUser.Name) == null)
     {
         _userService.Create(itemUser.Name, itemUser.Password, itemUser.BllRole);
     }
     return(RedirectToAction("Control"));
 }
Exemplo n.º 6
0
        //public static IDalEntity ToDal(this IBllEntity itemEntity)
        //{
        //    return null;
        //}

        public static DalUserEntity ToDal(this BllUserEntity itemUserEntity)
        {
            if (itemUserEntity == null)
            {
                return(null);
            }

            DalUserEntity dalUserEntity = new DalUserEntity
            {
                Id       = itemUserEntity.Id,
                Name     = itemUserEntity.Name,
                Password = itemUserEntity.Password,
                DalRole  = itemUserEntity.BllRole.ToDal()
            };

            return(dalUserEntity);
        }
Exemplo n.º 7
0
 private void Create(BllUserEntity user)
 {
     _userRepository.Create(user.ToDal());
     _unitOfWork.Commit();
 }