コード例 #1
0
        public async Task <IActionResult> PutPBonusTransactions([FromRoute] int id, [FromBody] PBonusTransactions pBonusTransactions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pBonusTransactions.Id)
            {
                return(BadRequest());
            }

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

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

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

            _context.BonusTransactions.Add(pBonusTransactions);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPBonusTransactions", new { id = pBonusTransactions.Id }, pBonusTransactions));
        }