public async Task <UserRoleConf> CreateUserRoleConf(GetUserRoleConfForEditOutput createUserRoleDto)
        {
            UserRoleConf userRole = new UserRoleConf
            {
                UserId = createUserRoleDto.UserId,
                RoleId = createUserRoleDto.RoleId
            };
            await _context.UserRoleConfs.AddAsync(userRole);

            await _context.SaveChangesAsync();

            return(userRole);
        }
        public async Task <GetUserRoleConfForViewDto> EditUserRoleConf(int id, GetUserRoleConfForEditOutput editOutput)
        {
            UserRoleConf userRole = await _context.UserRoleConfs.FirstOrDefaultAsync(i => i.Id == id);

            if (userRole != null)
            {
                userRole.UserId = editOutput.UserId;
                userRole.RoleId = editOutput.RoleId;
            }
            _context.UserRoleConfs.Update(userRole);
            await _context.SaveChangesAsync();

            var updatedRoleInfo = await GetUserRoleConf(userRole.Id);

            return(updatedRoleInfo);
        }
        public async Task <ActionResult <UserRoleConf> > CreateUserRoleConf(GetUserRoleConfForEditOutput createUserRoleDto)
        {
            if (!await _userRoleConfRepository.IsUserRoleUserIdRoleIdExists(createUserRoleDto.UserId, createUserRoleDto.RoleId))
            {
                return(BadRequest("User is Already Exists"));
            }

            if (!await _userRoleConfRepository.IsUserRoleUserIdExists(createUserRoleDto.UserId))
            {
                return(BadRequest("User is Already Assign a Role"));
            }

            var result = await _userRoleConfRepository.CreateUserRoleConf(createUserRoleDto);

            return(result);
        }
        public async Task <ActionResult <GetUserRoleConfForViewDto> > EditUserRoleConf(int id, GetUserRoleConfForEditOutput editOutput)
        {
            if (_userRoleConfRepository.IsUserRoleConfExists(id) == null)
            {
                return(BadRequest());
            }

            var userRole = await _userRoleConfRepository.EditUserRoleConf(id, editOutput);

            return(userRole);
        }