예제 #1
0
        public async Task <IActionResult> PutPhonghoc(Phonghoc phonghoc)
        {
            //if (id != phonghoc.Maphong)
            //{
            //    return BadRequest();
            //}

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <ActionResult <Phonghoc> > PostPhonghoc([FromBody] Phonghoc phonghoc)
        {
            _context.Phonghoc.Add(phonghoc);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PhonghocExists(phonghoc.Maphong))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPhonghoc", new { id = phonghoc.Maphong }, phonghoc));
        }