public async Task <IActionResult> Archive(string adId) { var ad = await advertisementService.GetByIdAsync(adId); if (ad == null) { return(RedirectToAction("All")); } await advertisementService.ArchiveByIdAsync(ad.Id); var notificationText = $"Your ad has been archived 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 archived 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 <IActionResult> Archive(string id) { if (!advertisementService.Contains(id)) { return(Redirect("/Home/Index")); } await advertisementService.ArchiveByIdAsync(id); await NotifyOnAdArchiveAsync(id); return(Redirect("/Home/Index")); }