예제 #1
0
        public Company Save(Company company)
        {
            var state = company.Id == 0 ? EntityState.Added : EntityState.Modified;

            context.Entry(company).State = state;
            context.SaveChanges();
            return(company);
        }
        public User Save(User user)
        {
            var state = user.Id == 0 ? EntityState.Added : EntityState.Modified;

            context.Entry(user).State = state;
            context.SaveChanges();
            return(user);
        }
        public Acceleration Save(Acceleration acceleration)
        {
            var state = acceleration.Id == 0 ? EntityState.Added : EntityState.Modified;

            context.Entry(acceleration).State = state;
            context.SaveChanges();
            return(acceleration);
        }
예제 #4
0
        public Models.Challenge Save(Models.Challenge challenge)
        {
            var status = challenge.Id == 0 ? EntityState.Added : EntityState.Modified;

            context.Entry(challenge).State = status;
            context.SaveChanges();
            return(challenge);
        }
예제 #5
0
        public Models.Challenge Save(Models.Challenge challenge)
        {
            var estado = challenge.Id == 0 ? EntityState.Added : EntityState.Modified;

            _contexto.Entry(challenge).State = estado;

            _contexto.SaveChanges();

            return(challenge);
        }
        public Acceleration Save(Acceleration acceleration)
        {
            var estado = acceleration.Id == 0 ? EntityState.Added : EntityState.Modified;

            _contexto.Entry(acceleration).State = estado;

            _contexto.SaveChanges();

            return(acceleration);
        }
예제 #7
0
        public User Save(User user)
        {
            var estado = user.Id == 0 ? EntityState.Added : EntityState.Modified;

            _contexto.Entry(user).State = estado;

            _contexto.SaveChanges();

            return(user);
        }
예제 #8
0
        public Models.Challenge Save(Models.Challenge challenge)
        {
            var estado = challenge.Id == 0 ? EntityState.Added : EntityState.Modified;

            //setar estado do entity
            _context.Entry(challenge).State = estado;

            //persistir os dados
            _context.SaveChanges();

            //retornar o objeto
            return(challenge);
        }
예제 #9
0
        public User Save(User user)
        {
            var estado = user.Id == 0 ? EntityState.Added : EntityState.Modified;

            //setar estado do entity
            _context.Entry(user).State = estado;

            //persistir os dados
            _context.SaveChanges();

            //retornar o objeto
            return(user);
        }
예제 #10
0
        public Company Save(Company company)
        {
            var estado = company.Id == 0 ? EntityState.Added : EntityState.Modified;

            //setar estado do entity
            _context.Entry(company).State = estado;

            //persistir os dados
            _context.SaveChanges();

            //retornar o objeto
            return(company);
        }
예제 #11
0
        public Acceleration Save(Acceleration acceleration)
        {
            var estado = acceleration.Id == 0 ? EntityState.Added : EntityState.Modified;

            //setar estado do entity
            _context.Entry(acceleration).State = estado;

            //persistir os dados
            _context.SaveChanges();

            //retornar o objeto
            return(acceleration);
        }
예제 #12
0
        public Company Save(Company company)
        {
            //verificar se é para Add ou Update
            var estado = company.Id == 0 ? EntityState.Added : EntityState.Modified;

            //salvar esse estado no contexto
            _context.Entry(company).State = estado;

            //persistir esses dados - salvá-los
            _context.SaveChanges();

            //retorna o objeto
            return(company);
        }
예제 #13
0
        public Models.Challenge Save(Models.Challenge challenge)
        {
            //verificar se é para Add ou Update
            var estado = challenge.Id == 0 ? EntityState.Added : EntityState.Modified;

            //salvar esse estado no contexto
            _context.Entry(challenge).State = estado;

            //persistir esses dados - salvá-los
            _context.SaveChanges();

            //retorna o objeto
            return(challenge);
        }
예제 #14
0
        public User Save(User user)
        {
            //verificar se é para Add ou Update
            var estado = user.Id == 0 ? EntityState.Added : EntityState.Modified;

            //salvar esse estado no contexto
            _context.Entry(user).State = estado;

            //persistir esses dados - salvá-los
            _context.SaveChanges();

            //retorna o objeto
            return(user);
        }
        public Acceleration Save(Acceleration acceleration)
        {
            //verificar se é para Add ou Update
            var estado = acceleration.Id == 0 ? EntityState.Added : EntityState.Modified;

            //salvar esse estado no contexto
            _context.Entry(acceleration).State = estado;

            //persistir esses dados - salvá-los
            _context.SaveChanges();

            //retorna o objeto
            return(acceleration);
        }
예제 #16
0
 public User Save(User user)
 {
     if (user.Id.Equals(0))
     {
         _context.Users.Add(user);
         _context.SaveChanges();
         return(user);
     }
     else
     {
         _context.Entry(user).State = EntityState.Modified;
         _context.SaveChanges();
         return(user);
     }
 }
        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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #20
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);
        }
        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);
        }
예제 #22
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);
        }
 public Models.Challenge Save(Models.Challenge challenge)
 {
     if (challenge.Id.Equals(0))
     {
         _context
         .Challenges
         .Add(challenge);
         _context
         .SaveChanges();
         return(challenge);
     }
     else
     {
         _context
         .Entry(challenge)
         .State = EntityState.Modified;
         _context.SaveChanges();
         return(challenge);
     }
 }
 public Acceleration Save(Acceleration acceleration)
 {
     if (acceleration.Id.Equals(0))
     {
         _context
         .Accelerations
         .Add(acceleration);
         _context
         .SaveChanges();
         return(acceleration);
     }
     else
     {
         _context
         .Entry(acceleration)
         .State = EntityState.Modified;
         _context.SaveChanges();
         return(acceleration);
     }
 }
 public Company Save(Company company)
 {
     if (company.Id.Equals(0))
     {
         _context
         .Companies
         .Add(company);
         _context
         .SaveChanges();
         return(company);
     }
     else
     {
         _context
         .Entry(company)
         .State = EntityState.Modified;
         _context.SaveChanges();
         return(company);
     }
 }
예제 #26
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);
        }