Exemplo n.º 1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Exemplo n.º 2
0
        public async Task <IActionResult> PutEntry(int id, Entry entry)
        {
            if (id != entry.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EntryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (DbUpdateException e)
            {
                return(ValidationProblem(new ValidationProblemDetails(new Dictionary <string, string[]>()
                {
                    { "Link", new string[] { "Model with this Shortcut already exists" } }
                })));
            }

            return(NoContent());
        }