Exemple #1
0
 public bool AddLikePhoto(Guid Id, Like like)
 {
     return dal.AddLikePhoto(Id, like);
 }
 public void CreateLike(Like like)
 {
     if(like == null)
     {
         throw new ArgumentNullException("like");
     }
     _dbContext.Likes.Add(like);
 }
        public void UpdateLike(Like like)
        {
            if(like == null)
               {
               throw new ArgumentNullException("like");
               }

            var existLike = _dbContext.Likes.FirstOrDefault(x => x.LikeId == like.LikeId);
            if(existLike == null)
            {
                throw new InvalidDataException("this like doesn't exist in current data base");
            }
            CopyLikeProperties(like,existLike);
        }
 private void CopyLikeProperties(Like fromLike, Like toLike)
 {
     if(fromLike == null)
     {
         throw new ArgumentNullException("fromLike");
     }
     if (toLike == null)
     {
         throw new ArgumentNullException("toLike");
     }
     toLike.CreateDate = fromLike.CreateDate;
     toLike.PresentationId = fromLike.PresentationId;
     toLike.User.UserId = fromLike.User.UserId;
 }
 public void DeleteLike(Like like)
 {
     if(like == null)
     {
         throw new ArgumentNullException("like");
     }
     var existLike = _dbContext.Likes.FirstOrDefault(x => x.LikeId == like.LikeId);
     if(existLike == null)
     {
         throw new InvalidDataException("this like doesn't exist in the current data base");
     }
     _dbContext.Likes.Remove(existLike);
 }