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);
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #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);
        }
Beispiel #6
0
        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);
        }
Beispiel #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);
        }
Beispiel #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);
        }