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); }
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); }
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); }
public User Save(User user) { var estado = user.Id == 0 ? EntityState.Added : EntityState.Modified; _contexto.Entry(user).State = estado; _contexto.SaveChanges(); return(user); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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 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) { 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); }
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); } }
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); }