Esempio n. 1
0
        public async Task <IActionResult> PutInvestigadores(string DNI, Investigadores investigadores)
        {
            if (DNI != investigadores.Dni)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult <Investigadores> > PostInvestigadores(Investigadores investigadores)
        {
            _context.Investigadores.Add(investigadores);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (InvestigadoresExists(investigadores.Dni))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetInvestigadores", new { DNI = investigadores.Dni }, investigadores));
        }