Summary

Class:ProjectX.Ef.Stores.ParticipationStore
Assembly:ProjectX.Ef
File(s):C:\private\projects\projectx\backend\src\ProjectX.Ef\Stores\ParticipationStore.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:58
Line coverage:0%

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
.ctor(...)1000
LoadParticipationAsync()1000
CreateParticipationAsync()5000
UpdateParticipationAsync()3000
DeleteParticipationAsync()3000

File(s)

C:\private\projects\projectx\backend\src\ProjectX.Ef\Stores\ParticipationStore.cs

#LineLine coverage
 1using System;
 2using System.Threading.Tasks;
 3using ProjectX.Entities;
 4using ProjectX.Stores;
 5using System.Linq;
 6
 7namespace ProjectX.Ef.Stores
 8{
 9    public class ParticipationStore : IParticipationStore
 10    {
 11        private readonly MainDbContext _dbContext;
 12
 013        public ParticipationStore(MainDbContext dbContext)
 14        {
 015            this._dbContext = dbContext;
 016        }
 17
 18        public async Task<Participation> LoadParticipationAsync(
 19            Guid eventId, Guid userId)
 20        {
 021            return this._dbContext.Participations.FirstOrDefault(c =>
 022                    c.EventId.Equals(eventId) &&
 023                    c.UserId.Equals(userId) &&
 024                    c.DeletedAt == null);
 25        }
 26
 27        public async Task<Participation> CreateParticipationAsync(
 28            Participation participation)
 29        {
 030            await this._dbContext.Participations.AddAsync(participation);
 31
 32            // TODO: move to some abstraction
 033            await this._dbContext.SaveChangesAsync();
 34
 035            return participation;
 36        }
 37
 38        public async Task<Participation> UpdateParticipationAsync(
 39            Participation participation)
 40        {
 041            this._dbContext.Participations.Attach(participation);
 42
 43            // TODO: move to some abstraction
 044            await this._dbContext.SaveChangesAsync();
 45
 046            return participation;
 47        }
 48
 49        public async Task DeleteParticipationAsync(
 50            Participation participation)
 51        {
 052            this._dbContext.Remove(participation);
 053            await this._dbContext.SaveChangesAsync();
 54        }
 55
 56
 57    }
 58}