Пример #1
0
        public async Task AddStateTracking(ObjectStateDto dto)
        {
            var objectState = ObjectStateDto.Map(dto);
            await _dbContext.AddAsync(objectState);

            await _dbContext.SaveChangesAsync();
        }
Пример #2
0
        public async Task DeleteById(int id)
        {
            var userToDelete = await _dbContext.Users.SingleOrDefaultAsync(u => u.Id == id);

            if (userToDelete != null)
            {
                _dbContext.Remove(userToDelete);
            }
            await _dbContext.SaveChangesAsync();
        }
Пример #3
0
        public async Task Create(UserRoleDto createUserRoleDto)
        {
            var userRole = new IdentityUserRole <int>
            {
                UserId = createUserRoleDto.UserId,
                RoleId = createUserRoleDto.RoleId
            };
            await _dbContext.UserRoles.AddAsync(userRole);

            await _dbContext.SaveChangesAsync();
        }
Пример #4
0
        public async Task <int> Create(CreateRoleDto createRoleDto)
        {
            var role = new Role
            {
                Name = createRoleDto.Name
            };
            await _dbContext.Roles.AddAsync(role);

            await _dbContext.SaveChangesAsync();

            return(role.Id);
        }
Пример #5
0
        public async Task AddRoleToState(RoleStateDto dto)
        {
            var roleState = RoleStateDto.Map(dto);
            await _dbContext.RoleStates.AddAsync(roleState);

            await _dbContext.SaveChangesAsync();
        }