< Summary

Information
Class: OzonRepositories.Data.OrderArchiveRepository
Assembly: OzonRepositories
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonRepositories/Data/OrderArchiveRepository.cs
Line coverage
100%
Covered lines: 36
Uncovered lines: 0
Coverable lines: 36
Total lines: 75
Line coverage: 100%
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%
Add()100%11100%
Delete()100%11100%
Get()100%11100%
GetAsync()100%11100%
GetAsync()100%11100%
Update()100%11100%
GetByOrderIdAsync()100%11100%
IsOrderArchivedAsync()100%11100%
GetArchivedOrdersWithDetailsAsync()100%11100%

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using OzonDomains.Models;
 3using OzonRepositories.Context;
 4
 5namespace OzonRepositories.Data
 6{
 7    public class OrderArchiveRepository : MainRepository, IRepository<OrderArchive>
 8    {
 159        public OrderArchiveRepository(ApplicationDbContext orderContext) : base(orderContext)
 10        {
 1511        }
 12
 13        public async Task<int> Add(OrderArchive value)
 14        {
 615            _context.OrderArchives.Add(value);
 616            return await _context.SaveChangesAsync();
 617        }
 18
 19        public async Task<int> Delete(OrderArchive value)
 20        {
 221            _context.OrderArchives.Remove(value);
 222            return await _context.SaveChangesAsync();
 223        }
 24
 25        public Task<List<OrderArchive>> Get()
 26        {
 127            return _context.OrderArchives
 128                .Include(oa => oa.Order)
 129                .ToListAsync();
 30        }
 31
 32        public async Task<OrderArchive?> GetAsync(int id)
 33        {
 234            return await _context.OrderArchives
 235                .FirstOrDefaultAsync(oa => oa.Id == id);
 236        }
 37
 38        public async Task<OrderArchive?> GetAsync(OrderArchive value)
 39        {
 240            return await _context.OrderArchives
 241                .FirstOrDefaultAsync(oa => oa.OrderId == value.OrderId);
 242        }
 43
 44        public async Task<int> Update(OrderArchive value)
 45        {
 146            _context.OrderArchives.Update(value);
 147            return await _context.SaveChangesAsync();
 148        }
 49
 50        public async Task<OrderArchive?> GetByOrderIdAsync(int orderId)
 51        {
 952            return await _context.OrderArchives
 953                .FirstOrDefaultAsync(oa => oa.OrderId == orderId);
 954        }
 55
 56        public async Task<bool> IsOrderArchivedAsync(int orderId)
 57        {
 558            return await _context.OrderArchives
 559                .AnyAsync(oa => oa.OrderId == orderId);
 560        }
 61
 62        public async Task<List<OrderArchive>> GetArchivedOrdersWithDetailsAsync()
 63        {
 264            return await _context.OrderArchives
 265                .Include(oa => oa.Order)
 266                .ThenInclude(o => o.AppStatus)
 267                .Include(oa => oa.Order)
 268                .ThenInclude(o => o.OzonClient)
 269                .Include(oa => oa.Order)
 270                .ThenInclude(o => o.ProductInfo)
 271                .OrderByDescending(oa => oa.ArchivedAt)
 272                .ToListAsync();
 273        }
 74    }
 75}