Exemplo n.º 1
0
        public async Task <IActionResult> PutEcrossing(short id, Ecrossing ecrossing)
        {
            if (id != ecrossing.EcrossingId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Ecrossing> > PostEcrossing(Ecrossing ecrossing)
        {
            _context.Ecrossing.Add(ecrossing);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (EcrossingExists(ecrossing.EcrossingId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetEcrossing", new { id = ecrossing.EcrossingId }, ecrossing));
        }