< Summary

Information
Class: FAU.DataAccess.Repositories.RolRepository
Assembly: FAU.DataAccess
File(s): /home/runner/work/Sistema.Liquidacion.BE/Sistema.Liquidacion.BE/FAU.DataAccess/Repositories/RolRepository.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 62
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetByIdAsync()100%11100%
GetByNombreAsync()100%11100%
GetAllAsync()100%11100%
CreateAsync()100%11100%
UpdateAsync()100%11100%
DeleteAsync()100%22100%
ExistsAsync()100%11100%

File(s)

/home/runner/work/Sistema.Liquidacion.BE/Sistema.Liquidacion.BE/FAU.DataAccess/Repositories/RolRepository.cs

#LineLine coverage
 1using FAU.Entidades;
 2using Microsoft.EntityFrameworkCore;
 3
 4namespace FAU.DataAccess.Repositories;
 5
 6public class RolRepository : IRolRepository
 7{
 8    private readonly ApplicationDbContext _context;
 9
 1110    public RolRepository(ApplicationDbContext context)
 11    {
 1112        _context = context;
 1113    }
 14
 15    public async Task<Rol?> GetByIdAsync(long id)
 16    {
 217        return await _context.Roles
 218            .FirstOrDefaultAsync(r => r.Id == id);
 219    }
 20
 21    public async Task<Rol?> GetByNombreAsync(string nombre)
 22    {
 223        return await _context.Roles
 224            .FirstOrDefaultAsync(r => r.Nombre == nombre);
 225    }
 26
 27    public async Task<IEnumerable<Rol>> GetAllAsync()
 28    {
 229        return await _context.Roles
 230            .ToListAsync();
 231    }
 32
 33    public async Task<Rol> CreateAsync(Rol rol)
 34    {
 135        _context.Roles.Add(rol);
 136        await _context.SaveChangesAsync();
 137        return rol;
 138    }
 39
 40    public async Task<Rol> UpdateAsync(Rol rol)
 41    {
 142        _context.Roles.Update(rol);
 143        await _context.SaveChangesAsync();
 144        return rol;
 145    }
 46
 47    public async Task DeleteAsync(long id)
 48    {
 149        var rol = await _context.Roles.FindAsync(id);
 150        if (rol != null)
 51        {
 152            _context.Roles.Remove(rol);
 153            await _context.SaveChangesAsync();
 54        }
 155    }
 56
 57    public async Task<bool> ExistsAsync(string nombre)
 58    {
 259        return await _context.Roles.AnyAsync(r => r.Nombre == nombre);
 260    }
 61}
 62