< Summary

Information
Class: OzonRepositories.Data.AccessProfileRepository
Assembly: OzonRepositories
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonRepositories/Data/AccessProfileRepository.cs
Line coverage
38%
Covered lines: 8
Uncovered lines: 13
Coverable lines: 21
Total lines: 46
Line coverage: 38%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetAllAsync()100%210%
GetByIdAsync()100%11100%
AddAsync()100%210%
UpdateAsync()100%210%
DeleteAsync()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonRepositories/Data/AccessProfileRepository.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using OzonDomains.Models.AccessControl;
 3using OzonRepositories.Context;
 4
 5namespace OzonRepositories.Data;
 6
 7public class AccessProfileRepository : MainRepository
 8{
 19    public AccessProfileRepository(ApplicationDbContext context) : base(context)
 10    {
 111    }
 12
 13    public async Task<List<AccessProfile>> GetAllAsync()
 14    {
 015        return await _context.AccessProfiles
 016            .Include(ap => ap.DataScopeSets)
 017            .ToListAsync();
 018    }
 19
 20    public async Task<AccessProfile?> GetByIdAsync(int id)
 21    {
 122        return await _context.AccessProfiles
 123            .Include(ap => ap.DataScopeSets)
 124                .ThenInclude(s => s.Items)
 125            .AsSplitQuery()
 126            .FirstOrDefaultAsync(ap => ap.Id == id);
 127    }
 28
 29    public async Task<int> AddAsync(AccessProfile profile)
 30    {
 031        _context.AccessProfiles.Add(profile);
 032        return await _context.SaveChangesAsync();
 033    }
 34
 35    public async Task<int> UpdateAsync(AccessProfile profile)
 36    {
 037        _context.AccessProfiles.Update(profile);
 038        return await _context.SaveChangesAsync();
 039    }
 40
 41    public async Task<int> DeleteAsync(AccessProfile profile)
 42    {
 043        _context.AccessProfiles.Remove(profile);
 044        return await _context.SaveChangesAsync();
 045    }
 46}