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);
        }
Пример #2
0
 public User Save(User user)
 {
     if (user.Id.Equals(0))
     {
         data.Add(user);
     }
     else
     {
         data.Update(user);
     }
     data.SaveChanges();
     return(user);
 }
Пример #3
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);
 }
Пример #5
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);
 }
Пример #8
0
 public User Save(User user)
 {
     if (_context.Users.Any(x => x == user))
     {
         _context.Update(user);
     }
     else
     {
         _context.Add(user);
     }
     _context.SaveChanges();
     return(user);
 }
Пример #9
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);
        }
Пример #11
0
        public Candidate Save(Candidate candidate)
        {
            if (MustInclude(candidate))
            {
                _context.Set <Candidate>().Add(candidate);
            }
            else
            {
                _context.Update <Candidate>(candidate);
            }

            _context.SaveChanges();
            return(candidate);
        }
Пример #12
0
        public Models.Challenge Save(Models.Challenge challenge)
        {
            if (challenge.Id == 0)
            {
                _context.Add(challenge);
                _context.SaveChanges();
            }
            else
            {
                _context.Update(challenge);
            }

            return(challenge);
        }
Пример #13
0
        public Acceleration Save(Acceleration acceleration)
        {
            if (acceleration.Id == 0)
            {
                _context.Add(acceleration);
            }
            else
            {
                _context.Update(acceleration);
            }

            _context.SaveChanges();
            return(acceleration);
        }
Пример #14
0
        public Company Save(Company company)
        {
            if (company.Id == 0)
            {
                _context.Add(company);
            }
            else
            {
                _context.Update(company);
            }

            _context.SaveChanges();
            return(company);
        }
        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);
        }
Пример #16
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);
        }
        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);
        }
Пример #18
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);
        }
Пример #19
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);
        }
Пример #20
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);
        }
Пример #21
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);
        }
Пример #22
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);
        }