public Submission Save(Submission submission)
        {
            var existe = _context.Submissions.Find(submission.UserId, submission.ChallengeId) == null
                ? _context.Add(submission) : _context.Update(submission.Score);

            _context.SaveChanges();

            return(submission);
        }
Ejemplo n.º 2
0
        public Acceleration Save(Acceleration acceleration)
        {
            if (acceleration.Id == 0)
            {
                _context.Add(acceleration);
                _context.SaveChanges();
            }

            return(acceleration);
        }
Ejemplo n.º 3
0
 public User Save(User user)
 {
     if (user.Id.Equals(0))
     {
         data.Add(user);
     }
     else
     {
         data.Update(user);
     }
     data.SaveChanges();
     return(user);
 }
Ejemplo n.º 4
0
 public Company Save(Company company)
 {
     if (_context.Companies.Any(x => x == company))
     {
         _context.Update(company);
     }
     else
     {
         _context.Add(company);
     }
     _context.SaveChanges();
     return(company);
 }
 public Models.Challenge Save(Models.Challenge challenge)
 {
     if (challenge.Id == 0)
     {
         data.Add(challenge);
     }
     else
     {
         data.Update(challenge);
     }
     data.SaveChanges();
     return(challenge);
 }
Ejemplo n.º 6
0
 public Acceleration Save(Acceleration acceleration)
 {
     if (acceleration.Id == 0)
     {
         data.Add(acceleration);
     }
     else
     {
         data.Update(acceleration);
     }
     data.SaveChanges();
     return(acceleration);
 }
 public Models.Challenge Save(Models.Challenge challenge)
 {
     if (_context.Challenges.Any(x => x == challenge))
     {
         _context.Update(challenge);
     }
     else
     {
         _context.Add(challenge);
     }
     _context.SaveChanges();
     return(challenge);
 }
 public Acceleration Save(Acceleration acceleration)
 {
     if (_context.Accelerations.Any(x => x == acceleration))
     {
         _context.Update(acceleration);
     }
     else
     {
         _context.Add(acceleration);
     }
     _context.SaveChanges();
     return(acceleration);
 }
Ejemplo n.º 9
0
 public User Save(User user)
 {
     if (_context.Users.Any(x => x == user))
     {
         _context.Update(user);
     }
     else
     {
         _context.Add(user);
     }
     _context.SaveChanges();
     return(user);
 }
Ejemplo n.º 10
0
 public Company Save(Company company)
 {
     if (company.Id == 0)
     {
         data.Add(company);
     }
     else
     {
         data.Update(company);
     }
     data.SaveChanges();
     return(company);
 }
        public User Save(User user)
        {
            if (user.Id == 0)
            {
                _context.Add(user);
                _context.SaveChanges();
            }
            else
            {
                _context.Update(user);
            }

            return(user);
        }
Ejemplo n.º 12
0
        public Models.Challenge Save(Models.Challenge challenge)
        {
            if (challenge.Id == 0)
            {
                _context.Add(challenge);
                _context.SaveChanges();
            }
            else
            {
                _context.Update(challenge);
            }

            return(challenge);
        }
Ejemplo n.º 13
0
        public Acceleration Save(Acceleration acceleration)
        {
            if (acceleration.Id == 0)
            {
                _context.Add(acceleration);
            }
            else
            {
                _context.Update(acceleration);
            }

            _context.SaveChanges();
            return(acceleration);
        }
Ejemplo n.º 14
0
        public Company Save(Company company)
        {
            if (company.Id == 0)
            {
                _context.Add(company);
            }
            else
            {
                _context.Update(company);
            }

            _context.SaveChanges();
            return(company);
        }
        public Candidate Save(Candidate candidate)
        {
            try
            {
                var findCandidate = FindById(candidate.UserId, candidate.AccelerationId, candidate.CompanyId);

                return(findCandidate);
            }
            catch (Exception)
            {
                _context.Add(candidate);
                _context.SaveChanges();

                return(candidate);
            }
        }
        public Submission Save(Submission submission)
        {
            var search = _context.Submissions.Where(x => x.UserId == submission.UserId && x.ChallengeId == submission.ChallengeId).FirstOrDefault();

            if (search == null)
            {
                _context.Add(submission);
                _context.SaveChanges();
            }
            else
            {
                _context.Update(submission);
            }

            return(submission);
        }
        public Submission Save(Submission submission)
        {
            Submission submissionExists = data.Submissions.Find(submission.UserId, submission.ChallengeId);

            if (submissionExists == null)
            {
                data.Add(submission);
            }
            else
            {
                data.Entry(submissionExists).State = EntityState.Detached;
                data.Update(submission);
            }
            data.SaveChanges();
            return(submission);
        }
Ejemplo n.º 18
0
        public Candidate Save(Candidate candidate)
        {
            Candidate candidateExists = FindById(candidate.UserId, candidate.AccelerationId, candidate.CompanyId);

            if (candidateExists == null)
            {
                data.Add(candidate);
            }
            else
            {
                data.Entry(candidateExists).State = EntityState.Detached;
                data.Update(candidate);
            }
            data.SaveChanges();
            return(candidate);
        }
Ejemplo n.º 19
0
        public Submission Save(Submission submission)
        {
            var submissionFromContext = _context.Submissions.Find(submission.UserId, submission.ChallengeId);

            if (submissionFromContext == null)
            {
                _context.Add(submission);
            }
            else
            {
                _context.Entry(submissionFromContext).State = EntityState.Detached;
                _context.Update(submission);
            }

            _context.SaveChanges();
            return(submission);
        }
        public Candidate Save(Candidate candidate)
        {
            Candidate candidateResult = FindById(candidate.UserId, candidate.AccelerationId, candidate.CompanyId);

            if (candidateResult == null)
            {
                _context.Add(candidate);
                candidateResult = candidate;
            }
            else
            {
                candidateResult.Status    = candidate.Status;
                candidateResult.CreatedAt = candidate.CreatedAt;
            }
            _context.SaveChanges();
            return(candidate);
        }
Ejemplo n.º 21
0
        public Candidate Save(Candidate candidate)
        {
            var candidateFromContext = _context.Candidates.Find(candidate.UserId, candidate.AccelerationId, candidate.CompanyId);

            if (candidateFromContext == null)
            {
                _context.Add(candidate);
            }
            else
            {
                _context.Entry(candidateFromContext).State = EntityState.Detached;
                _context.Update(candidate);
            }

            _context.SaveChanges();
            return(candidate);
        }
Ejemplo n.º 22
0
        public Submission Save(Submission submission)
        {
            Submission submissionResult = _context.Submissions
                                          .FirstOrDefault(s => s.UserId == submission.UserId && s.ChallengeId == submission.ChallengeId);

            if (submissionResult == null)
            {
                _context.Add(submission);
                submissionResult = submission;
            }
            else
            {
                submissionResult.Score     = submission.Score;
                submissionResult.CreatedAt = submission.CreatedAt;
            }
            _context.SaveChanges();
            return(submission);
        }
Ejemplo n.º 23
0
        public Submission Save(Submission submission)
        {
            Submission su = _context.Submissions.FirstOrDefault(x => x.UserId == submission.UserId &&
                                                                x.ChallengeId == submission.ChallengeId);

            if (su == null)
            {
                _context.Add(submission);
            }
            else
            {
                _context.Entry(_context.Submissions
                               .FirstOrDefault(x => x.UserId == submission.UserId && x.ChallengeId == submission.ChallengeId))
                .CurrentValues.SetValues(submission);
            }

            _context.SaveChanges();
            return(submission);
        }
Ejemplo n.º 24
0
        public Company Save(Company company)
        {
            var state = _contexto.Entry(company).State;

            var existe = _contexto.Companies.AsNoTracking().Where(x => x.Id == company.Id);

            if (existe == null)
            {
                _contexto.Add(company);
            }
            else
            {
                _contexto.Update(company);
            }

            _contexto.SaveChanges();

            return(company);
        }
Ejemplo n.º 25
0
        public Candidate Save(Candidate candidate)
        {
            //var state = _contexto.Entry(candidate).State;
            var existe = _contexto.Candidates.Find(candidate.AccelerationId, candidate.CompanyId, candidate.UserId);

            if (existe == null)
            {
                _contexto.Add(candidate);
            }
            else
            {
                //_contexto.Update(candidate);
                existe.Status = candidate.Status;
            }

            _contexto.SaveChanges();

            return(candidate);
        }
Ejemplo n.º 26
0
        public Submission Save(Submission submission)
        {
            // var state = _contexto.Entry(submission).State;

            var existe = _contexto.Submissions.Find(submission.ChallengeId, submission.UserId);

            if (existe == null)
            {
                _contexto.Add(submission);
            }
            else
            {
                //_contexto.Update(submission);
                existe.Score = submission.Score;
            }

            _contexto.SaveChanges();

            return(submission);
        }
Ejemplo n.º 27
0
        public Submission Save(Submission submission)
        {
            var submissionExists = _context
                                   .Submissions
                                   .Any(s => s.UserId == submission.UserId &&
                                        s.ChallengeId == submission.ChallengeId);

            if (submissionExists)
            {
                _context.Update(submission);
            }
            else
            {
                _context.Add(submission);
            }

            _context.SaveChanges();

            return(submission);
        }
Ejemplo n.º 28
0
        public Candidate Save(Candidate candidate)
        {
            Candidate ca = _context.Candidates
                           .FirstOrDefault(x => x.UserId == candidate.UserId &&
                                           x.AccelerationId == candidate.AccelerationId &&
                                           x.CompanyId == candidate.CompanyId);

            if (ca == null)
            {
                _context.Add(candidate);
            }
            else
            {
                _context.Entry(_context.Candidates
                               .FirstOrDefault(x => x.UserId == candidate.UserId && x.AccelerationId == candidate.AccelerationId && x.CompanyId == candidate.CompanyId))
                .CurrentValues.SetValues(candidate);
            }

            _context.SaveChanges();
            return(candidate);
        }
Ejemplo n.º 29
0
        public Candidate Save(Candidate candidate)
        {
            var candidateExists = _context
                                  .Candidates
                                  .Any(x => x.UserId == candidate.UserId &&
                                       x.AccelerationId == candidate.AccelerationId &&
                                       x.CompanyId == candidate.CompanyId);


            if (!candidateExists)
            {
                _context.Add(candidate);
            }
            else
            {
                _context.Update(candidate);
            }

            _context.SaveChanges();

            return(candidate);
        }