public void FillWith <T>() where T : class
 {
     using (var context = new CodenationContext(FakeOptions))
     {
         if (context.Set <T>().Count() == 0)
         {
             foreach (T item in GetFakeData <T>())
             {
                 context.Set <T>().Add(item);
             }
             context.SaveChanges();
         }
     }
 }
Exemple #2
0
 public IList <User> FindByAccelerationName(string name)
 {
     return(_context.Set <Acceleration>().
            Where(acceleration => acceleration.Name == name).
            Join(_context.Set <Candidate>(),
                 acceleration => acceleration.Id,
                 candidate => candidate.AccelerationId,
                 (acceleration, candidate) => candidate).
            Join(_context.Set <User>(),
                 candidate => candidate.UserId,
                 user => user.Id,
                 (candidate, user) => user).
            Distinct().
            ToList());
 }
Exemple #3
0
 public IList <Company> FindByAccelerationId(int accelerationId)
 {
     return(_context.Set <Acceleration>().
            Where(acceleration => acceleration.Id == accelerationId).
            Join(_context.Set <Candidate>(),
                 acceleration => acceleration.Id,
                 candidate => candidate.AccelerationId,
                 (acceleration, candidate) => candidate).
            Join(_context.Set <Company>(),
                 candidate => candidate.CompanyId,
                 company => company.Id,
                 (candidate, company) => company).
            Distinct().
            ToList());;
 }
Exemple #4
0
 public IList <Submission> FindByChallengeIdAndAccelerationId(int challengeId, int accelerationId)
 {
     return(_context.Set <Candidate>().
            Where(candidate => candidate.AccelerationId == accelerationId).
            Join(_context.Set <User>(),
                 candidate => candidate.UserId,
                 user => user.Id,
                 (candidate, user) => user).
            Join(_context.Set <Submission>(),
                 user => user.Id,
                 submission => submission.UserId,
                 (user, submission) => submission).
            Where(submission => submission.ChallengeId == challengeId).
            Distinct().
            ToList());;
 }
Exemple #5
0
 public IList <Models.Challenge> FindByAccelerationIdAndUserId(int accelerationId, int userId)
 {
     return(_context.Set <User>().
            Where(user => user.Id == userId).
            Join(_context.Set <Candidate>(),
                 user => user.Id,
                 candidate => candidate.UserId,
                 (user, candidate) => candidate).
            Join(_context.Set <Acceleration>(),
                 candidate => candidate.AccelerationId,
                 acceleration => acceleration.Id,
                 (candidate, acceleration) => acceleration).
            Where(acceleration => acceleration.Id == accelerationId).
            Join(_context.Set <Models.Challenge>(),
                 acceleration => acceleration.ChallengeId,
                 challenge => challenge.Id,
                 (acceleration, challenge) => challenge).
            Distinct().
            ToList());;
 }
 public IList <Candidate> FindByAccelerationId(int accelerationId)
 {
     return(_context.Set <Candidate>().Where(p => p.AccelerationId == accelerationId).ToList());
 }
Exemple #7
0
 public virtual string Cadastrar(T entity)
 {
     _contexto.Set <T>().Add(entity);
     _contexto.SaveChanges();
     return(MensagensErro.Ok);
 }