コード例 #1
0
        public async Task <IActionResult> PutTcrossSection(short id, TcrossSection tcrossSection)
        {
            if (id != tcrossSection.TcrossSectionId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <TcrossSection> > PostTcrossSection(TcrossSection tcrossSection)
        {
            _context.TcrossSection.Add(tcrossSection);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TcrossSectionExists(tcrossSection.TcrossSectionId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTcrossSection", new { id = tcrossSection.TcrossSectionId }, tcrossSection));
        }