コード例 #1
0
        public async Task <IActionResult> PutEventTicketHistory([FromRoute] Guid id, [FromBody] EventTicketHistory eventTicketHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eventTicketHistory.EventTicketHistoryId)
            {
                return(BadRequest());
            }

            _context.Entry(eventTicketHistory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventTicketHistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PostEventTicketHistory([FromBody] EventTicketHistory eventTicketHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.EventTicketHistories.Add(eventTicketHistory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEventTicketHistory", new { id = eventTicketHistory.EventTicketHistoryId }, eventTicketHistory));
        }