public void Delete(DalLike dalEntity) { if (dalEntity == null) { throw new ArgumentNullException("dalEntity", "Like is null"); } var entity = _context.Set<Likes>().Find(dalEntity.Id); _context.Set<Likes>().Remove(entity); }
public void Create(DalLike dalEntity) { if (dalEntity == null) { throw new ArgumentNullException("dalEntity", "Like is null"); } _context.Set<Likes>().Add(new Likes() { UserId = dalEntity.UserId, PictureId = dalEntity.PictureId }); }
public void Update(DalLike dalEntity) { if (dalEntity == null) { throw new ArgumentNullException("dalEntity", "Like is null"); } var oldEntity = _context.Set<Likes>().Find(dalEntity.Id); if (oldEntity != null) { var oldContextEntry = _context.Entry(oldEntity); Likes newEntity = new Likes() { LikeId = dalEntity.Id, UserId = dalEntity.UserId, PictureId = dalEntity.PictureId }; oldContextEntry.CurrentValues.SetValues(newEntity); oldContextEntry.State = EntityState.Modified; } }