public ActionResult Create() { var user = new BllUserEntity(); var roles = _roleService.GetAll().ToList(); ViewBag.Roles = new SelectList(roles, "Id", "Name"); return(PartialView("Create", user)); }
public ActionResult Edit(BllUserEntity itemUser, int role) { if (itemUser != null) { itemUser.BllRole = _roleService.GetById(role); _userService.Update(itemUser); } return(RedirectToAction("Control")); }
public override bool IsUserInRole(string username, string roleName) { BllUserEntity user = UserService.Contains(username); if (user != null && user.BllRole.Name == roleName) { return(true); } return(false); }
public bool Update(BllUserEntity item) { var user = _userRepository.GetById(item.Id); if (user == null) { return(false); } _userRepository.Update(item.ToDal()); _unitOfWork.Commit(); return(true); }
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")); }
//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); }
private void Create(BllUserEntity user) { _userRepository.Create(user.ToDal()); _unitOfWork.Commit(); }