public async Task <IActionResult> Ban(string adId) { var ad = await advertisementService.GetByIdAsync(adId); if (ad == null) { return(RedirectToAction("All")); } await advertisementService.BanByIdAsync(ad.Id); var notificationText = $"Your ad has been banned by admin - '{ad.Name}'"; var actionLink = $"/User/Profile?id={ad.Id}"; var notificationToAdOwner = await notificationService.CreateNotificationAsync(notificationText, actionLink); await notificationService.AssignNotificationToUserAsync(notificationToAdOwner.Id, ad.UserId); notificationText = $"Ad in your wishlist has been banned by admin - '{ad.Name}'"; actionLink = $"/User/Wishlist"; var usersIds = await userAdWishlistService.GetAllUserIdsThatHaveAdInWishlistAsync(ad.Id); var notificationToAllUsersThatHaveAdInWishlist = await notificationService.CreateNotificationAsync(notificationText, actionLink); await notificationService.AssignNotificationToUsersAsync(notificationToAllUsersThatHaveAdInWishlist.Id, usersIds.ToList()); return(RedirectToAction("All")); }
public async Task <bool> ApproveByIdAsync(string id) { var report = context.Reports.SingleOrDefault(r => r.Id == id); if (report == null) { return(false); } await advertisementService.BanByIdAsync(report.ReportedAdvertisementId); await ArchiveByIdAsync(report.Id); return(true); }