コード例 #1
0
 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);
 }
コード例 #2
0
 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
     });
 }
コード例 #3
0
 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;
     }
 }