Beispiel #1
0
        public IHttpActionResult ReactivateVoteById(VoteEdit vote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            VoteService voteService = new VoteService();

            if (!voteService.ReactivateVoteById(vote))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Beispiel #2
0
        public bool ReactivateVoteById(VoteEdit vote)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var voteToReactivate =
                    ctx
                    .Votes
                    .Single(e => e.VoteId == vote.VoteId);

                if (voteToReactivate.IsDeleted)
                {
                    voteToReactivate.IsDeleted   = false;
                    voteToReactivate.ModifiedUtc = DateTimeOffset.UtcNow;
                }
                return(ctx.SaveChanges() == 1);
            }
        }