public async Task <IActionResult> RemoveProduce(int id, [FromBody] ProduceDto produceDTO) { var shop = await _context.Shops.FindAsync(id); if (shop == null) { return(NotFound()); } if (shop.OwnerId != AuthenticatedUserId()) { return(Unauthorized("Shop does not belong to you")); } var produce = await _context.Produce .Where(p => p.ShopId == id && p.Name == produceDTO.Name) .FirstOrDefaultAsync(); if (produce == null) { return(BadRequest("No such produce")); } _context.Remove(produce); await _context.SaveChangesAsync(); return(NoContent()); }
public void Delete(Word word) { //var entity = Get(id); _context.Remove(word); _context.SaveChanges(); }
public IActionResult Delete(int id) { var equip = db.Equips.FirstOrDefault(x => x.EquipID == id); if (equip != null) { db.Remove(equip); db.SaveChanges(); return(Ok(equip)); } return(NotFound()); }
public IActionResult Delete(int id) { using var context = new WebApiContext(); var result = context.Categories.Find(id); if (result == null) { return(NotFound()); } context.Remove(result); context.SaveChanges(); return(NoContent()); }
public void Delete(TodoItem todoItem) { _context.Remove(todoItem); _context.SaveChanges(); }