< Summary

Information
Class: OzonRepositories.Data.OzonChatResponseTimeRepository
Assembly: OzonRepositories
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonRepositories/Data/OzonChatResponseTimeRepository.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 35
Coverable lines: 35
Total lines: 70
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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()0%620%
GetAsync()0%620%
Update()100%210%
GetByChatIdAsync()100%210%
GetByClientIdAsync()100%210%

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using OzonDomains.Models;
 3using OzonRepositories.Context;
 4
 5namespace OzonRepositories.Data
 6{
 7    public class OzonChatResponseTimeRepository : MainRepository, IRepository<OzonChatResponseTime>
 8    {
 09        public OzonChatResponseTimeRepository(ApplicationDbContext orderContext) : base(orderContext)
 10        {
 011        }
 12
 13        public async Task<int> Add(OzonChatResponseTime value)
 14        {
 015            await _context.OzonChatResponseTimes.AddAsync(value);
 016            return await _context.SaveChangesAsync();
 017        }
 18
 19        public async Task<int> Delete(OzonChatResponseTime value)
 20        {
 021            _context.OzonChatResponseTimes.Remove(value);
 022            return await _context.SaveChangesAsync();
 023        }
 24
 25        public async Task<List<OzonChatResponseTime>> Get()
 26        {
 027            return await _context.OzonChatResponseTimes
 028                .Include(x => x.Client)
 029                .OrderByDescending(x => x.RecordedAt)
 030                .ToListAsync();
 031        }
 32
 33        public async Task<OzonChatResponseTime?> GetAsync(int id)
 34        {
 035            return await _context.OzonChatResponseTimes
 036                .Include(x => x.Client)
 037                .FirstOrDefaultAsync(x => x.Id == id) ?? new OzonChatResponseTime();
 038        }
 39
 40        public async Task<OzonChatResponseTime?> GetAsync(OzonChatResponseTime value)
 41        {
 042            return await _context.OzonChatResponseTimes
 043                .Include(x => x.Client)
 044                .FirstOrDefaultAsync(x => x.Id == value.Id) ?? new OzonChatResponseTime();
 045        }
 46
 47        public async Task<int> Update(OzonChatResponseTime value)
 48        {
 049            value.CreatedAt = value.CreatedAt; // nothing special
 050            _context.OzonChatResponseTimes.Update(value);
 051            return await _context.SaveChangesAsync();
 052        }
 53
 54        public async Task<List<OzonChatResponseTime>> GetByChatIdAsync(string chatId)
 55        {
 056            return await _context.OzonChatResponseTimes
 057                .Where(x => x.ChatId == chatId)
 058                .OrderByDescending(x => x.RecordedAt)
 059                .ToListAsync();
 060        }
 61
 62        public async Task<List<OzonChatResponseTime>> GetByClientIdAsync(int clientId)
 63        {
 064            return await _context.OzonChatResponseTimes
 065                .Where(x => x.ClientId == clientId)
 066                .OrderByDescending(x => x.RecordedAt)
 067                .ToListAsync();
 068        }
 69    }
 70}