Esempio n. 1
0
        public async Task <ActionResult <ModelCarYear> > PostModelCarYear(ModelCarYear modelCarYear)
        {
            _context.ModelCarYear.Add(modelCarYear);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetModelCarYear", new { id = modelCarYear.Id }, modelCarYear));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutModelCarYear(int id, ModelCarYear modelCarYear)
        {
            if (id != modelCarYear.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }