< Summary

Information
Class: OzonRepositories.Data.OzonClientRepository
Assembly: OzonRepositories
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonRepositories/Data/OzonClientRepository.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 59
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
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%
Delete()100%210%
Get()100%210%
GetAsync()100%210%
GetAsync()100%210%
Update()0%620%

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using OzonDomains.Models;
 3using OzonRepositories.Context;
 4
 5namespace OzonRepositories.Data
 6{
 7    public class OzonClientRepository : MainRepository, IRepository<OzonClient>
 8    {
 09        public OzonClientRepository(ApplicationDbContext orderContext) : base(orderContext)
 10        {
 011        }
 12
 13        public async Task<int> Add(OzonClient value)
 14        {
 015            await _context.OzonClients.AddAsync(value);
 016            return await _context.SaveChangesAsync();
 017        }
 18
 19        public async Task<int> Delete(OzonClient value)
 20        {
 021            _context.OzonClients.Remove(value);
 022            return await _context.SaveChangesAsync();
 023        }
 24
 25        public async Task<List<OzonClient>> Get()
 26        {
 027            return await _context.OzonClients.ToListAsync();
 028        }
 29
 30        public async Task<OzonClient?> GetAsync(int id)
 31        {
 032            return await _context.OzonClients.FirstOrDefaultAsync(p => p.Id == id);
 033        }
 34
 35        public async Task<OzonClient?> GetAsync(OzonClient value)
 36        {
 037            await Task.CompletedTask;
 038            return _context.OzonClients.FirstOrDefault(p => p.Name == value.Name);
 039        }
 40
 41        public async Task<int> Update(OzonClient value)
 42        {
 043            var ordetToUpdate = _context.OzonClients.FirstOrDefault(o => o.Id == value.Id);
 044            if (ordetToUpdate == null)
 045                return 0;
 46
 047            ordetToUpdate.Name = value.Name;
 048            ordetToUpdate.ApiKey = value.ApiKey;
 049            ordetToUpdate.ClientId = value.ClientId;
 050            ordetToUpdate.CurrencyCode = value.CurrencyCode;
 051            ordetToUpdate.INNCode = value.INNCode;
 052            ordetToUpdate.WarehouseName = value.WarehouseName;
 53
 054            _context.OzonClients.Update(ordetToUpdate);
 55
 056            return await _context.SaveChangesAsync();
 057        }
 58    }
 59}