Beispiel #1
0
        public async Task <ActionResult <HarmfulSubstance> > PostHarmfulSubstance(HarmfulSubstance harmfulSubstance)
        {
            _context.HarmfulSubstances.Add(harmfulSubstance);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHarmfulSubstance", new { id = harmfulSubstance.Id }, harmfulSubstance));
        }
Beispiel #2
0
        public async Task <IActionResult> PutHarmfulSubstance(int id, HarmfulSubstance harmfulSubstance)
        {
            if (id != harmfulSubstance.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }