コード例 #1
0
        public async Task <bool> Archive(Archive archive)
        {
            bool isArchive = false;

            try
            {
                var archived = await GetArchive(archive);

                if (archived != null)
                {
                    return(await DeleteArchive(archived.Id));
                }

                await _context.Archives.AddAsync(archive);

                await _context.SaveChangesAsync();

                isArchive = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(isArchive);
        }
コード例 #2
0
        /// <summary>
        /// Delete Comment
        /// </summary>
        /// <param name="id">Comment ID</param>
        /// <returns>saved changes</returns>
        public async Task DeleteCoAsync(int id)
        {
            Comments comment = await _context.Comments.FindAsync(id);

            if (comment != null)
            {
                _context.Remove(comment);
                await _context.SaveChangesAsync();
            }
        }
コード例 #3
0
        /// <summary>
        /// Delete Post
        /// </summary>
        /// <param name="id">post id</param>
        /// <returns>view</returns>
        public async Task DeleteAsync(int id)
        {
            Post post = await _context.Posts.FindAsync(id);

            if (post != null)
            {
                _context.Remove(post);
                await _context.SaveChangesAsync();
            }
        }
コード例 #4
0
ファイル: LikeRepository.cs プロジェクト: JhonasV/ProjectGram
        public async Task <bool> DeleteLike(Likes like)
        {
            bool isLikeDeleted = false;

            try
            {
                like = await GetLikeDetails(like);

                _context.Likes.Remove(like);
                await _context.SaveChangesAsync();

                isLikeDeleted = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(isLikeDeleted);
        }
コード例 #5
0
        public async Task <bool> RemoveCommentLike(int commentLikeId)
        {
            var isDeleted = false;

            try
            {
                var commentLike = await this.GetCommentLikes(commentLikeId);

                _context.CommentLikes.Remove(commentLike);
                await _context.SaveChangesAsync();

                isDeleted = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(isDeleted);
        }
コード例 #6
0
ファイル: FotoRepository.cs プロジェクト: JhonasV/ProjectGram
        public async Task <bool> BorrarFotoAlbum(int fotoId)
        {
            bool success = false;

            try
            {
                Foto detalles = await _context.Foto.Where(x => x.Id == fotoId)
                                .Include(f => f.Likes)
                                .Include(f => f.Comments)
                                .Include(f => f.Archives)
                                .FirstOrDefaultAsync();

                _context.Foto.Remove(detalles);
                await _context.SaveChangesAsync();

                success = true;
            }
            catch (Exception)
            {
            }

            return(success);
        }
コード例 #7
0
        public async Task <bool> AddComment(Comment comment)
        {
            try
            {
                _context.Comment.Add(comment);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(false);
        }
コード例 #8
0
        public async Task <bool> SaveNotification(Notification notification)
        {
            var isNotificationAdded = false;

            try
            {
                await _context.Notifications.AddAsync(notification);

                await _context.SaveChangesAsync();

                isNotificationAdded = true;
                SendClientNotification();
            }
            catch (Exception)
            {
                throw;
            }
            return(isNotificationAdded);
        }