public IHttpActionResult PutVotingSession(VotingSession votingSession)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(votingSession).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VotingSessionExists(votingSession.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult PutVoter(Voter voter)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(voter).State = EntityState.Modified;
            foreach (var question in voter.SecretQuestions)
            {
                if (question.Id == 0)
                {
                    db.Entry(question).State = EntityState.Added;
                }
                else
                {
                    db.Entry(question).State = EntityState.Modified;
                }
            }

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VoterExists(voter.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void SaveChanges()
 {
     _dbContext.SaveChanges();
 }
Beispiel #4
0
 public void Insert(TEntity entity)
 {
     _dbSet.Add(entity);
     _dbContext.SaveChanges();
 }