コード例 #1
0
        public static RoleModelMVC RoleModelBLToRoleModelDA(RoleModelBL role)
        {
            var newRole = new RoleModelMVC()
            {
                Id   = role.Id,
                Name = role.Name,
                //Users = new List<UserModelMVC>()
            };

            if (role.Users == null)
            {
                return(newRole);
            }

            newRole.Users = new List <UserModelMVC>();

            role.Users.ToList().ForEach(s => newRole.Users.Add(new UserModelMVC
            {
                Id       = s.Id,
                Login    = s.Login,
                Password = s.Password,
                IsActive = s.IsActive
            }));

            return(newRole);
        }
コード例 #2
0
ファイル: RoleService.cs プロジェクト: alena4324/CourseWork
        public bool CreateRole(RoleModelBL role)
        {
            var newRole = _roleRepository.GetRoleByName(role.Name);

            if (newRole != null)
            {
                return(false);
            }

            _roleRepository.Create(RoleMapBL.RoleModelBLToRoleModelDA(role));

            return(true);
        }