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); }
/// <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(); } }
/// <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(); } }
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); }
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); }
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); }
public async Task <bool> AddComment(Comment comment) { try { _context.Comment.Add(comment); await _context.SaveChangesAsync(); return(true); } catch (Exception e) { e.ToString(); } return(false); }
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); }