예제 #1
0
 /// <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);
     }
 }
예제 #2
0
        public FamilyMember DeleteMember(FamilyMember member)
        {
            var memberTobeDeleted = _context.FamilyMembers.FirstOrDefault(x => x.Id == member.Id);

            dbSet.Remove(memberTobeDeleted);
            _context.SaveChanges();
            return(memberTobeDeleted);
        }
예제 #3
0
        public IActionResult Delete(int id)
        {
            var b = _bikes.Where(x => x.Id == id).FirstOrDefault();

            if (b != null)
            {
                _bikes.Remove(b);
            }
            return(Ok());
        }