Exemplo n.º 1
0
        public ActionResult FilterFriends(string findName, string findCity, string findAge, string findEmail)
        {
            ErrorEnum result;
            var       userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out result);
            var       friends   = new List <UserModel>();

            try
            {
                friends = FriendshipManager.RetrieveNoFriends(userModel, findCity, Int32.Parse(findAge), findName, findEmail, out result);
            }
            catch (Exception)
            {
                friends = FriendshipManager.RetrieveNoFriends(userModel, findCity, null, findName, findEmail, out result);
            }

            if (result == ErrorEnum.NoErrors)
            {
                return(View("FindFriends", friends));
            }
            else
            {
                //TODO TRATAR ERRO
                ViewBag.ErrorMessage = result;
                return(View("FindFriends", null));
            }
        }
Exemplo n.º 2
0
        public override void Entry(IModHelper helper)
        {
            this.Config = helper.ReadConfig <ModConfig>();

            this.manager = new FriendshipManager(Config, Monitor);

            helper.Events.GameLoop.SaveLoaded   += this.OnSaveLoaded;
            helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
        }
Exemplo n.º 3
0
        public ActionResult MyFriends()
        {
            ErrorEnum error;
            var       userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out error);

            if (userModel == null)
            {
                userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out error);
            }

            return(View("Friends", FriendshipManager.RetrieveFriendsRelations(new Guid(User.Identity.Name))));
        }
Exemplo n.º 4
0
        public bool RemoveFriend(Guid friendID)
        {
            ErrorEnum error;
            var       userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out error);

            if (userModel == null)
            {
                userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out error);
            }

            bool removed = FriendshipManager.RemoveFriendship(new Guid(User.Identity.Name), friendID);

            return(removed);
        }
Exemplo n.º 5
0
        public bool AddFriend(string friendID)
        {
            ErrorEnum result;
            var       userModel      = UserManager.RetrieveUser(new Guid(User.Identity.Name), out result);
            var       sendInvitation = FriendshipManager.InviteFriend(userModel, new Guid(friendID), out result);

            if (sendInvitation)
            {
                return(true);
            }
            else
            {
                ViewBag.ErrorMessage = result;
                return(false);
            }
        }
Exemplo n.º 6
0
        public bool AcceptFriend(string userID)
        {
            ErrorEnum error;
            var       userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out error);

            if (userModel == null)
            {
                userModel = UserManager.RetrieveUser(new Guid(userID), out error);
            }

            bool accepted = FriendshipManager.AcceptFriend(userModel.ID, new Guid(userID), out error);

            if (error == ErrorEnum.NoErrors)
            {
                NotificationsManager.AddFriendAcceptedNotification(new Guid(userID), userModel.FullName);
                return(true);
            }
            else
            {
                ViewBag.ErrorMessage = error;
                return(false);
            }
        }
Exemplo n.º 7
0
        public ActionResult FindFriends()
        {
            ErrorEnum result;
            var       userModel = UserManager.RetrieveUser(new Guid(User.Identity.Name), out result);

            if (userModel == null)
            {
                var userID = User.Identity.Name;
                userModel             = UserManager.RetrieveUser(new Guid(userID), out result);
                Session["LoggedUser"] = userModel;
            }
            var friends = FriendshipManager.FindFriends(userModel, out result);

            if (result == ErrorEnum.NoErrors)
            {
                return(View("FindFriends", friends));
            }
            else
            {
                // TODO: DEFINIR ERRO
                ViewBag.ErrorMessage = result;
                return(View("FindFriends"));
            }
        }
Exemplo n.º 8
0
        public List <UserModel> MutualFriends(long currentUserId, long userId)
        {
            List <User> mutualFriends = FriendshipManager.MutualFriends(currentUserId, userId) as List <User>;

            return(mutualFriends.Select(a => Mapper.Mapper.AutoMap <User, UserModel>(a)).ToList());
        }
Exemplo n.º 9
0
 public void DeleteFriend(long friendId, long currentUserId)
 {
     FriendshipManager.DeleteFriend(friendId, currentUserId);
 }
Exemplo n.º 10
0
 public void DeclineRequest(long currentUserId, long friendId)
 {
     FriendshipManager.DeclineRequest(currentUserId, friendId);
 }
Exemplo n.º 11
0
        public FriendshipModel AcceptRequest(long currentUserId, long friendId)
        {
            var acceptedRequest = FriendshipManager.AcceptRequest(currentUserId, friendId);

            return(Mapper.Mapper.Map(acceptedRequest));
        }
Exemplo n.º 12
0
        public FriendshipModel Add(AddFriendshipModel model, long currentUserId)
        {
            var friendship = FriendshipManager.Add(Mapper.Mapper.Map(model, currentUserId), currentUserId);

            return(Mapper.Mapper.Map(friendship));
        }
Exemplo n.º 13
0
        public List <UserModel> SearchMyFriends(long currentUserId, string criteria)
        {
            var friends = FriendshipManager.SearchMyFriends(currentUserId, criteria);

            return(friends.Select(a => Mapper.Mapper.AutoMap <User, UserModel>(a)).ToList());
        }
Exemplo n.º 14
0
 public PagedList <User> GetAllMyFriends(long currentUserId, ResourceParameters usersResourceParameters)
 {
     return(FriendshipManager.GetAllMyFriends(currentUserId, usersResourceParameters) as PagedList <User>);
 }
Exemplo n.º 15
0
        public List <UserModel> GetAllMyFriends(long currentUserId)
        {
            List <User> friends = FriendshipManager.GetAllMyFriends(currentUserId) as List <User>;

            return(friends.Select(a => Mapper.Mapper.AutoMap <User, UserModel>(a)).ToList());
        }
Exemplo n.º 16
0
        public List <FriendshipModel> SentFriendRequests(long currentUserId)
        {
            var sentRequests = FriendshipManager.SentFriendRequests(currentUserId);

            return(sentRequests.Select(request => Mapper.Mapper.Map(request)).ToList());
        }
Exemplo n.º 17
0
        public FriendshipModel GetFriendInfo(long friendId, long currentUserId)
        {
            var friendInfo = FriendshipManager.GetFriendInfo(friendId, currentUserId);

            return(Mapper.Mapper.Map(friendInfo));
        }