예제 #1
0
        public IActionResult CreatePollRanking([FromBody] PollRanking item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.PollRankings.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetPollRanking", new { id = item.Id }, item));
        }
예제 #2
0
        public IActionResult UpdatePollRanking(int id, [FromBody] PollRanking item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            var pollRanking = _context.PollRankings.FirstOrDefault(t => t.Id == id);

            if (pollRanking == null)
            {
                return(NotFound());
            }

            pollRanking.PollId     = item.PollId;
            pollRanking.OptionId   = item.OptionId;
            pollRanking.Rank       = item.Rank;
            pollRanking.ModifyDate = DateTime.UtcNow;

            _context.PollRankings.Update(pollRanking);
            _context.SaveChanges();

            return(new NoContentResult());
        }