/// <summary> /// Adds the specified entity. /// </summary> /// <param name="entity">The entity.</param> public T Add(T entity) { try { //_dbContext.Context.Entry(entity).State = System.Data.Entity.EntityState.Added; _dbSet.Add(entity); _dbContext.SaveChanges(); return(entity); } catch (Exception dbEx) { _dbSet.Remove(entity); return(null); } }
public FamilyMember DeleteMember(FamilyMember member) { var memberTobeDeleted = _context.FamilyMembers.FirstOrDefault(x => x.Id == member.Id); dbSet.Remove(memberTobeDeleted); _context.SaveChanges(); return(memberTobeDeleted); }
public IActionResult Delete(int id) { var b = _bikes.Where(x => x.Id == id).FirstOrDefault(); if (b != null) { _bikes.Remove(b); } return(Ok()); }