Beispiel #1
0
        public async Task <IActionResult> PostThamso([FromBody] Thamso thamso)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Thamso.Add(thamso);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ThamsoExists(thamso.MaTs))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetThamso", new { id = thamso.MaTs }, thamso));
        }
Beispiel #2
0
        public async Task <IActionResult> PutThamso([FromRoute] string id, [FromBody] Thamso thamso)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != thamso.MaTs)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }