public async Task <IActionResult> AcceptFriendRequiest(Guid notificationId, Guid friendId) { try { if (notificationId == Guid.Empty || friendId == Guid.Empty) { return(NotFound()); } await _notificationApiAccess.MarkNotificationAsSeen(_userId, notificationId); await _friendApiAccess.AddFriend(_userId, new RelationToAdd { FriendId = friendId, SinceWhen = DateTime.Now }); return(RedirectToAction("Notifications", "Profile")); } catch (Exception ex) { _logger.LogError($"Something went wrong during adding friend by user {_userId} to user {friendId}. Notification id: {notificationId}"); _logger.LogError($"Exception info: {ex.Message} {ex.Source}"); return(RedirectToAction("Error", "Error")); } }
public async Task <ActionResult <List <NotificationWithBasicFromWhoData> > > Notifications() { try { IEnumerable <NotificationWithBasicFromWhoData> notifications = (await _notificationApiAccess.GetNotifications(_userId)); foreach (var notification in notifications) { await _notificationApiAccess.MarkNotificationAsSeen(_userId, notification.Notification.Id); } return(View(notifications.ToList())); } catch (Exception ex) { _logger.LogError($"Something went wrong during loading user: {_userId} notifications"); _logger.LogError($"Exception info: {ex.Message} {ex.Source}"); return(RedirectToAction("Error", "Error")); } }