< Summary

Information
Class: OzonRepositories.Data.MatchedRowRepository
Assembly: OzonRepositories
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonRepositories/Data/MatchedRowRepository.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 28
Coverable lines: 28
Total lines: 66
Line coverage: 0%
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%210%
Add()100%210%
AddRange()100%210%
<AddRange()100%210%
Delete()100%210%
Get()100%210%
GetAsync()100%210%
GetAsync()100%210%
Update()100%210%

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using OzonDomains.Models.MatchedRowSys;
 3using OzonRepositories.Context;
 4using OzonRepositories.Utils;
 5using System.Text.Json;
 6
 7
 8namespace OzonRepositories.Data
 9{
 10    public class MatchedRowRepository : MainRepository, IRepository<MatchedRow>
 11    {
 012        public MatchedRowRepository(ApplicationDbContext orderContext) : base(orderContext)
 13        {
 014        }
 15
 16        public async Task<int> Add(MatchedRow value)
 17        {
 018            _context.MatchedRows.Add(value);
 019            return await _context.SaveChangesAsync();
 020        }
 21
 22        public async Task<int> AddRange(List<MatchedRow> values)
 23        {
 024            return await TransactionHelper.ExecuteInTransactionAsync(_context, async (transaction) =>
 025            {
 026                _context.MatchedRows.AddRange(values);
 027                var result = await _context.SaveChangesAsync();
 028                return result;
 029            });
 030        }
 31
 32
 33        public async Task<int> Delete(MatchedRow value)
 34        {
 035            _context.MatchedRows.Remove(value);
 036            return await _context.SaveChangesAsync();
 037        }
 38
 39        public async Task<List<MatchedRow>> Get()
 40        {
 041            return await _context.MatchedRows.ToListAsync();
 042        }
 43
 44        public async Task<MatchedRow?> GetAsync(int id)
 45        {
 046            return await _context.MatchedRows.FirstOrDefaultAsync(m => m.Id == id);
 047        }
 48
 49        public async Task<MatchedRow?> GetAsync(MatchedRow value)
 50        {
 051            var file1DataSerialized = JsonSerializer.Serialize(value.File1Data);
 052            var file2DataSerialized = JsonSerializer.Serialize(value.File2Data);
 53
 054            return await _context.MatchedRows.FirstOrDefaultAsync(m =>
 055                m.File1DataSerialized == file1DataSerialized &&
 056                m.File2DataSerialized == file2DataSerialized);
 057        }
 58
 59        public async Task<int> Update(MatchedRow value)
 60        {
 061            _context.MatchedRows.Update(value);
 062            return await _context.SaveChangesAsync();
 063        }
 64    }
 65
 66}