Esempio n. 1
0
        public async Task <IActionResult> PutEmpleat(long id, Empleat empleat)
        {
            if (id != empleat.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] Empleat empleat)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != empleat.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                _data.Update(empleat);
                var save = await _data.SaveAsync(empleat);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmpleatExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }