Esempio n. 1
0
 public virtual void InsertOrUpdate(TEntity entity)
 {
     if (entity.Id == default(int))
     {
         _dbSet.Add(entity);
     }
     else
     {
         _db.Entry(entity).State = EntityState.Modified;
     }
 }
        public async Task <IActionResult> PutAccreditor([FromRoute] int id, [FromBody] Accreditor accreditor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }