Exemplo n.º 1
0
        public async Task <IActionResult> UnFriend(string id)
        {
            var user = _profileImplementation.GetById(id);

            var userId       = _profileManager.GetUserId(User);
            var usertmp      = _profileManager.FindByIdAsync(userId).Result;
            var connectModel = new ConnectingList
            {
                Sender   = usertmp,
                Receiver = user
            };


            await _userImplementation.UnFriend(connectModel);

            var notificationModel = new Notification {
                notification = " removed you from connection list",
                DateTime     = DateTime.Now,
                UserFrom     = usertmp,
                UserTo       = user,
                Controller   = "Profile",
                Action       = "Details",
                ActionId     = userId
            };
            await _profileImplementation.AddNotification(notificationModel);

            return(RedirectToAction("Details", new { id }));
        }
Exemplo n.º 2
0
 private ConnectingList BuildRequest(ConnectingList connectModel)
 {
     return(new ConnectingList
     {
         Sender = connectModel.Sender,
         Receiver = connectModel.Receiver
     });
 }
Exemplo n.º 3
0
        public IActionResult Details(string id)
        {
            var user         = _profileImplementation.GetById(id);
            var userRoles    = _profileManager.GetRolesAsync(user).Result;
            var userId       = _profileManager.GetUserId(User);
            var usertmp      = _profileManager.FindByIdAsync(userId).Result;
            var connectModel = new ConnectingList
            {
                Sender   = usertmp,
                Receiver = user
            };
            var hasSendRequest = _profileImplementation.GetByRequestId(connectModel);
            var Notifications  = new List <Notification>();

            Notifications = _profileImplementation.GetNotifications(usertmp).ToList();
            var notificationListing = Notifications.Select(notification => new NotificationModel
            {
                notification = notification.notification,
                DateTime     = notification.DateTime,
                UserFrom     = notification.UserFrom.UserName,
                Controller   = notification.Controller,
                Action       = notification.Action,
                ActionId     = notification.ActionId
            });
            var model = new ProfileModel()
            {
                RequestOption = hasSendRequest,
                OpenUserId    = userId,
                UserId        = user.Id,
                UserName      = user.UserName,
                UserRating    = user.Rating,
                MemberSince   = user.MemberSince,
                Email         = user.Email,
                IsAdmin       = userRoles.Contains("Admin"),
                notifications = notificationListing
            };

            return(View(model));
        }