Пример #1
0
        private void ToSettingsPage_Click(object sender, RoutedEventArgs e)
        {
            UserFriends userFriends = new UserFriends(user);

            userFriends.Show();
            this.Close();
        }
Пример #2
0
        /// <summary>
        /// Notifies and removes a player session
        /// </summary>
        /// <param name="netMsg"></param>
        private void OnPlayerDisconnection(NetworkMessage netMsg)
        {
            Debug.Log($"A player with id {netMsg.Sender.connectionId} has disconnected from the Server");
            var disconnectedPlayerSession = SessionManager.Find(netMsg.Sender.connectionId);

            if (disconnectedPlayerSession != null)
            {
                var removedPlayerFriends         = UserFriends.GetAll(disconnectedPlayerSession.Id);
                List <NetworkClient> groupToSend = new List <NetworkClient>();

                if (removedPlayerFriends.Count > 0)
                {
                    foreach (var friend in removedPlayerFriends)
                    {
                        if (SessionManager.Exists(friend.Id))
                        {
                            var friendSession = SessionManager.Find(friend.Id);
                            if (friendSession != null)
                            {
                                groupToSend.Add(friendSession.conn);
                            }
                        }
                    }
                }

                if (groupToSend.Count > 0)
                {
                    Server.SendToGroup(groupToSend, LoginEvent.PLAYER_FRIENDS_LOGOUT, disconnectedPlayerSession.Id);
                }
            }

            SessionManager.Remove(netMsg.Sender.connectionId);
        }
Пример #3
0
        public void RemoveUserFriend(Guid UserId, Guid FriendUserId)
        {
            UserFriends userFriend = db.UserFriends.Where(x => x.UserId.Equals(UserId) && x.FriendUserId.Equals(FriendUserId)).FirstOrDefault();

            db.UserFriends.Remove(userFriend);
            db.SaveChanges();
        }
Пример #4
0
        private UserManagementUsersViewModel MapPlexUser(UserFriends plexInfo, PlexUsers dbUser, DateTime lastLoggedIn)
        {
            var newUser = false;

            if (dbUser == null)
            {
                newUser = true;
                dbUser  = new PlexUsers();
            }
            var features    = (Features)dbUser?.Features;
            var permissions = (Permissions)dbUser?.Permissions;

            var m = new UserManagementUsersViewModel
            {
                Id = plexInfo.Id,
                PermissionsFormattedString = newUser ? "Processing..." :(permissions == 0 ? "None" : permissions.ToString()),
                FeaturesFormattedString    = newUser ? "Processing..." : features.ToString(),
                Username     = plexInfo.Title,
                Type         = UserType.PlexUser,
                EmailAddress = plexInfo.Email,
                Alias        = dbUser?.UserAlias ?? string.Empty,
                LastLoggedIn = lastLoggedIn,
                PlexInfo     = new UserManagementPlexInformation
                {
                    Thumb = plexInfo.Thumb
                },
                ManagedUser = string.IsNullOrEmpty(plexInfo.Username)
            };

            m.Permissions.AddRange(GetPermissions(permissions));
            m.Features.AddRange(GetFeatures(features));

            return(m);
        }
Пример #5
0
        public async Task Accept(string senderId, string recipientId)
        {
            var friendShip = await Get(senderId, recipientId);

            if (friendShip != null)
            {
                throw new ValidationException("This user already your friend", recipientId);
            }

            await CreateFriendAccountIfNotExist(new FriendDTO { FriendId = recipientId });

            await CreateFriendAccountIfNotExist(new FriendDTO { FriendId = senderId });

            var friends = new UserFriends
            {
                UserId   = senderId,
                FriendId = recipientId
            };

            _appContext.UserFriends.Add(friends);

            var requestForRemove = await _appContext.Requests
                                   .FirstAsync(r => r.SenderUserId == senderId && r.RecipientUserId == recipientId);

            _appContext.Requests.Remove(requestForRemove);

            await _appContext.SaveChangesAsync();
        }
Пример #6
0
        public void UnFollow(int id)
        {
            UserFriends model = context.UserFriends.Where(k => k.Id == id).FirstOrDefault();

            context.UserFriends.Remove(model);
            context.SaveChanges();
        }
Пример #7
0
        public async Task <bool> AddFriendAsync(Guid userFromId, Guid userToId)
        {
            var friendship = await GetExistingFriendship(userFromId, userToId);

            if (friendship != null && friendship.Status == (int)FriendStatus.Deleted)
            {
                friendship.Status = (int)FriendStatus.InFriends;
                await _context.SaveChangesAsync();

                return(true);
            }

            UserFriends userFriends = await CreateUserFriendsEntityAsync(userFromId, userToId);

            if (_context.UserFriends.Any(uf => // if friend is already added
                                         Equals(userFromId, uf.UserFromId) && Equals(userToId, uf.UserToId)))
            {
                return(true); // nothing changes
            }

            try
            {
                _context.UserFriends.Add(userFriends);
                await _context.SaveChangesAsync();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        ///Accepting In anotherProfile
        public IActionResult AcceptFriend2(string Id, string myId)
        {
            //IfHeWasAnOldFriend
            UserFriends F1 = ProfileContext.UserFriends.FirstOrDefault(x => x.FriendId == Id && x.UserId == myId && x.IsApproved == false && x.IsDeleted == false);
            UserFriends F2 = ProfileContext.UserFriends.FirstOrDefault(x => x.UserId == Id && x.FriendId == myId && x.IsApproved == false && x.IsDeleted == false);

            if (F1 != null && F2 != null)
            {
                F1.IsDeleted = false;
                F2.IsDeleted = false;
                ProfileContext.SaveChanges();
                return(RedirectToAction("AnonFriendORNot", new { Id = myId, IDD = Id }));
            }

            UserFriends UF = ProfileContext.UserFriends.FirstOrDefault(u => u.FriendId == Id && u.UserId == myId);

            UF.IsApproved = true;
            UserFriends UF2 = new UserFriends()
            {
                UserId     = Id,
                FriendId   = myId,
                IsDeleted  = false,
                IsApproved = true
            };

            ProfileContext.UserFriends.Add(UF2);
            ProfileContext.SaveChanges();
            return(RedirectToAction("AnonFriendORNot", new { Id = myId, IDD = Id }));
        }
Пример #9
0
        public IEnumerable <User> GetFriends()
        {
            var userFriends     = UserFriends.Select(u => u.User);
            var userIsAFriendOf = UserIsAFriendOf.Select(u => u.Friend);

            return(userFriends.Concat(userIsAFriendOf));
        }
Пример #10
0
 public int AddFriend([FromBody] UserFriends userFriends)
 {
     userFriends.AddedDate   = DateTime.Now;
     userFriends.UpdatedDate = DateTime.Now;
     db.UserFriends.Add(userFriends);
     return(db.SaveChanges());
 }
Пример #11
0
        public ActionResult ConnectWithYourself()
        {
            var _user = SessionSet <User> .Get("login");

            int FriendId = SessionSet <User> .Get("login").Id;

            int myId = _user.Id;

            UserFriends uf0 = new UserFriends();

            uf0.UserId     = myId;
            uf0.FriendId   = FriendId;
            uf0.CreateDate = DateTime.Now;

            var result = postRepo.Query <UserFriends>().Where(k => (k.UserId == uf0.UserId) && (k.FriendId == uf0.FriendId)).FirstOrDefault();

            if (result == null)
            {
                db.UserFriends.Add(uf0);
                db.SaveChanges();
            }


            return(RedirectToAction("Index", "Home"));
        }
Пример #12
0
        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            _isSuccess = 1;

            var         cacheSet    = new ShareCacheStruct <UserFriends>();
            UserFriends userFriend  = cacheSet.FindKey(ContextUser.UserId, _friendID);
            UserFriends userFriend1 = cacheSet.FindKey(_friendID, ContextUser.UserId);

            if (userFriend == null)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St9104_NotFriendsUserID;
                return(false);
            }

            //Console.WriteLine("***" + userFriend1.UserID);
            //如果原来是好友 要将对方的状态改为关注 其他的直接删除
            if (userFriend.FriendType == FriendType.Friend)
            {
                cacheSet.Delete(userFriend);
                if (userFriend1 != null)
                {
                    userFriend1.FriendType = FriendType.Attention;
                }
            }
            else
            {
                cacheSet.Delete(userFriend);
            }

            return(true);
        }
        public IActionResult AddFriend(string Id, string myId)
        {
            //Id ellli mb3otlooo =>friendId
            //myId eliii hyb3aat =>usrId
            //LwKan mawgod we etmasaaa777
            UserFriends F1 = ProfileContext.UserFriends.FirstOrDefault(x => x.UserId == Id && x.FriendId == myId && x.IsDeleted == true);
            UserFriends F2 = ProfileContext.UserFriends.FirstOrDefault(x => x.FriendId == Id && x.UserId == myId && x.IsDeleted == true);

            if (F1 != null && F2 != null)

            {
                F1.IsDeleted  = false;
                F1.IsApproved = false;
                F2.IsDeleted  = false;
                F2.IsApproved = false;
                ProfileContext.SaveChanges();
                return(RedirectToAction("AnonFriendORNot", new { Id = myId, IDD = Id }));
            }
            //LwAwelMaraAb3atloRequest
            UserFriends UF = new UserFriends();

            UF.FriendId   = myId;
            UF.UserId     = Id;
            UF.IsDeleted  = false;
            UF.IsApproved = false;
            ProfileContext.UserFriends.Add(UF);
            ProfileContext.SaveChanges();
            return(RedirectToAction("AnonFriendORNot", new { Id = myId, IDD = Id }));
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);
            try
            {
                if (!Page.IsPostBack && !Page.IsCallback)
                {
                    ServiceReference service = new ServiceReference("~/DesktopModules/ATI_Base/resources/services/StreamService.asmx");
                    service.InlineScript = true;
                    ScriptManager.GetCurrent(Page).Services.Add(service);

                    aqufitEntities entities = new aqufitEntities();
                    // First thing we want to do here is to varify that the people are really friends
                    if (ProfileSettings != null)    // if profilesettins is null .. then this is the user opening the send interface from their "Inbox"
                    {
                        UserFriends friend = entities.UserFriends.FirstOrDefault(f => (f.SrcUserSettingKey == UserSettings.Id && f.DestUserSettingKey == ProfileSettings.Id) || (f.SrcUserSettingKey == ProfileSettings.Id && f.DestUserSettingKey == UserSettings.Id));
                        if (friend != null)
                        {
                            Affine.Data.User friendProfile = entities.UserSettings.OfType <User>().FirstOrDefault(f => f.UserKey == ProfileSettings.UserKey && f.PortalKey == this.PortalId);
                            atiSendMessage.UserSettings = new UserSettings[] { friendProfile };
                        }
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #15
0
        protected void bUpload_Click(object sender, EventArgs e)
        {
            if (fileUpload.HasFile)
            {
                try
                {
                    long usId = this.UserSettings.Id;
                    if (GroupSettings != null)
                    {
                        aqufitEntities entities = new aqufitEntities();
                        UserFriends    uf       = entities.UserFriends.FirstOrDefault(f => f.SrcUserSettingKey == UserSettings.Id && f.DestUserSettingKey == GroupSettings.Id || f.SrcUserSettingKey == GroupSettings.Id && f.DestUserSettingKey == UserSettings.Id);
                        if (uf != null && (uf.Relationship == (short)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER || uf.Relationship == (short)Affine.Utils.ConstsUtil.Relationships.GROUP_ADMIN))
                        {   // Relation
                            usId = GroupSettings.Id;
                        }
                        else
                        {
                            lStatus.Text = "You must be a group admin to change the profile picture.";
                        }
                    }

                    if (fileUpload.PostedFile.ContentType == "image/jpeg" || fileUpload.PostedFile.ContentType == "image/png" || fileUpload.PostedFile.ContentType == "image/jpg" || fileUpload.PostedFile.ContentType == "image/gif" || fileUpload.PostedFile.ContentType == "image/pjpeg" || fileUpload.PostedFile.ContentType == "image/x-png")
                    {
                        if (fileUpload.PostedFile.ContentLength < 10072000)
                        {
                            MemoryStream ms = new MemoryStream(fileUpload.FileBytes);
                            Affine.Utils.ImageUtil.AlbumType type = Utils.ImageUtil.AlbumType.PROFILE;
                            bool cover = true;
                            if (Request["sap"] != null)
                            {
                                type  = Utils.ImageUtil.AlbumType.STREAM;
                                cover = false;
                            }
                            else
                            {
                                Affine.Utils.ImageUtil.MakeImageProfilePic(ms, usId);
                            }
                            long           pId      = Affine.Utils.ImageUtil.SavePhoto(type, ms, usId, -1, userPhotoPath, urlPath, cover);
                            string         control  = Request["c"];
                            aqufitEntities entities = new aqufitEntities();
                            Photo          photo    = entities.UserAttachments.OfType <Photo>().FirstOrDefault(p => p.Id == pId);
                            ScriptManager.RegisterStartupScript(this, Page.GetType(), "atiProfileRefresh", " parent.Aqufit.Page." + control + ".ImageUploadSuccess(" + usId + "," + pId + ", '" + photo.ThumbUri + "');", true);
                        }
                        else
                        {
                            lStatus.Text = "Upload status: The file has to be less than 9 MB!";
                        }
                    }
                    else
                    {
                        lStatus.Text = "Upload status: Only JPEG, PNG, GIF files are accepted! (" + fileUpload.PostedFile.ContentType + ")";
                    }
                }
                catch (Exception ex)
                {
                    lStatus.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
        }
Пример #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserFriends userFriends = db.UserFriends.Find(id);

            db.UserFriends.Remove(userFriends);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #17
0
 public void RemoveFromUnconfirmedFriends(User user)
 {
     if (!UserFriends.Contains(user))
     {
         throw new Exception($"Cannot remove user {user.Name} from friends list, it does't contains this user ");
     }
     UserFriends.Remove(user);
 }
Пример #18
0
        public async Task GetUserFriends_Ervelan_ShouldParseErvelanFriends()
        {
            UserFriends friends = await jikan.GetUserFriends("Ervelan");

            Assert.NotNull(friends);
            Assert.True(friends.Friends.Count > 20);
            Assert.Contains("SonMati", friends.Friends.Select(x => x.Username));
            Assert.Contains("Progeusz", friends.Friends.Select(x => x.Username));
        }
Пример #19
0
        public void ShouldParseErvelanFriends()
        {
            UserFriends friends = Task.Run(() => jikan.GetUserFriends("Ervelan")).Result;

            Assert.NotNull(friends);
            Assert.True(friends.Friends.Count > 20);
            Assert.Contains("SonMati", friends.Friends.Select(x => x.Username));
            Assert.Contains("Progeusz", friends.Friends.Select(x => x.Username));
        }
Пример #20
0
        public async Task <IActionResult> AddFriend(string friendId)
        {
            var  userId = _userManager.GetUserId(User);
            User user   = await _unitOfWork.Users.GetUserWithFollowedAndFollowing(userId);

            User friend = await _unitOfWork.Users.GetUserWithFollowedAndFollowing(friendId);

            if (friend == null)
            {
                return(RedirectToAction("ListUsers"));
            }

            if (friend.Id != user.Id)
            {
                UserFriends friends1 = new UserFriends {
                    User = user, UserId = user.Id, Friend = friend, FriendId = friend.Id
                };
                UserFriends friends2 = new UserFriends {
                    User = friend, UserId = friend.Id, Friend = user, FriendId = user.Id
                };

                if (!user.Following.Contains(friends1))
                {
                    user.Following.Add(friends1);
                    //user.FollowedBy.Add(friends2);
                }

                if (!friend.Following.Contains(friends2))
                {
                    friend.Following.Add(friends2);
                    //friend.FollowedBy.Add(friends1);
                }

                int    cmp      = String.Compare(user.Id, friend.Id);
                string roomName = (cmp <= 0 ? user.Id : friend.Id) + "_" + (cmp <= 0 ? friend.Id : user.Id);

                ChatRoom room = await _unitOfWork.ChatRooms.GetByName(roomName);

                if (room == null)
                {
                    ChatRoom chat = new ChatRoom
                    {
                        ChatType = ChatType.Private,
                        RoomName = roomName
                    };

                    chat.Users.Add(user);
                    chat.Users.Add(friend);

                    _unitOfWork.ChatRooms.Add(chat);
                }
                await _unitOfWork.Complete();
            }

            return(RedirectToAction("ListUsers"));
        }
        //ToRedirectToSameViewi'min because i can remove from Two Places
        public IActionResult RemoveFriend2(string Id, string IDD)
        {
            UserFriends UF1 = ProfileContext.UserFriends.FirstOrDefault(u => u.FriendId == Id && u.UserId == IDD);
            UserFriends UF2 = ProfileContext.UserFriends.FirstOrDefault(u => u.UserId == Id && u.FriendId == IDD);

            ProfileContext.UserFriends.Remove(UF1);
            ProfileContext.UserFriends.Remove(UF2);
            ProfileContext.SaveChanges();
            return(RedirectToAction("AnonFriendORNot", new { Id = IDD, IDD = Id }));
        }
        public IActionResult AddFriendToList(string friendEmail)
        {
            UserFriends userFriends = new UserFriends {
            };

            userFriends.UserEmail = User.Identity.Name;
            userFriends.Friend    = friendEmail;

            return(RedirectToAction("UserFriends", new { email = userFriends.UserEmail }));
        }
Пример #23
0
 public ActionResult Edit([Bind(Include = "Id,UserId,FriendId")] UserFriends userFriends)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userFriends).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", userFriends.UserId);
     return(View(userFriends));
 }
Пример #24
0
        public GenericOperationResult <IActionResult> AddFriend(string userName)
        {
            var result = new GenericOperationResult <IActionResult>();

            try
            {
                int userId = int.Parse(httpContext.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier));
                if (unitOfWork.Authentication.UserExists(userName) && userId != default)
                {
                    var         friend     = unitOfWork.UserRepository.GetByUserName(userName);
                    var         user       = unitOfWork.UserRepository.GetById(userId);
                    UserFriends userFriend = new UserFriends
                    {
                        FriendId = friend.Id,
                        UserId   = userId,
                        Friend   = friend,
                        User     = user
                    };
                    unitOfWork.UserFriendsRepository.Create(userFriend);
                    if (unitOfWork.SaveChanges())
                    {
                        result.Data = new OkResult();
                        result.Messages.Add("Your friend has been added");
                        result.Status = OperationResultStatusEnum.Succeeded;
                        return(result);
                    }
                    result.Data = new BadRequestResult();
                    result.Messages.Add("Insucessful process");
                    result.Status = OperationResultStatusEnum.Failed;
                    return(result);
                }
            }
            catch (ArgumentNullException e)
            {
                throw new BusinessException("Argument is null ", e);
            }
            catch (SqlException e)
            {
                throw new BusinessException("Database error ", e);
            }
            catch (NullReferenceException e)
            {
                throw new BusinessException("Object Refrence is null ", e);
            }
            catch (Exception e)
            {
                throw new BusinessException("error Occured ", e);
            }
            result.Data = new BadRequestResult();
            result.Messages.Add("Friend userName doesn't exist");
            result.Status = OperationResultStatusEnum.Failed;
            return(result);
        }
Пример #25
0
        public ActionResult Create([Bind(Include = "Id,UserId,FriendId")] UserFriends userFriends)
        {
            if (ModelState.IsValid)
            {
                db.UserFriends.Add(userFriends);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", userFriends.UserId);
            return(View(userFriends));
        }
Пример #26
0
 public void AddFriend(User user)
 {
     if (user == null)
     {
         throw new Exception("Can not add non existing user to Friend's");
     }
     if (UserFriends.Contains(user))
     {
         throw new Exception($"User {user.Name} with id {user.Id} is alredy on Fiends list");
     }
     UserFriends.Add(user);
 }
Пример #27
0
        // GET: UserFriends/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserFriends userFriends = db.UserFriends.Find(id);

            if (userFriends == null)
            {
                return(HttpNotFound());
            }
            return(View(userFriends));
        }
Пример #28
0
        /// <summary>
        /// Handler a request to0 retrieve aa player friends
        /// </summary>
        /// <param name="netMsg"></param>
        private void OnPlayerFriendsRequest(NetworkMessage netMsg)
        {
            var userId  = SessionManager.GetPlayerId(netMsg.Sender);
            var friends = UserFriends.GetAll(userId);

            if (friends.Count > 0)
            {
                _server.SendToClient(netMsg.Sender, GameEvent.PLAYER_FRIENDS_SUCCESS, friends);
            }
            else
            {
                Debug.Warning("He has none so just send a event error message type saying it");
            }
        }
Пример #29
0
        public void RemoveFromFriends(User friend)
        {
            if (Id == friend.Id)
            {
                throw new Exception("You can not remove yourself");
            }

            UserFriends.Where(f => f.User.Id == friend.Id || f.Friend.Id == friend.Id)
            .ToList()
            .ForEach(userFriend =>
            {
                UserFriends.Remove(userFriend);
            });
        }
Пример #30
0
        // GET: UserFriends/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserFriends userFriends = db.UserFriends.Find(id);

            if (userFriends == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", userFriends.UserId);
            return(View(userFriends));
        }
Пример #31
0
        private void UpdateGroup()
        {
            if (Page.IsValid)
            {
                try
                {
                    // check required fields
                    aqufitEntities entities = new aqufitEntities();
                    Group group = entities.UserSettings.OfType<Group>().Include("GroupType").Include("UserSettingsExtendeds").Include("Places").FirstOrDefault(g => g.Id == GroupSettings.Id);

                    group.UserEmail = atiTxtGroupEmail.Text;
                    group.UserFirstName = txtGroupName.Text;
                    Place place = group.Places.FirstOrDefault();
                    if (place != null)
                    {
                        place.Description = atTxtGroupDescription.Text;
                    }
                    int gtype = Convert.ToInt32(ddlGroupType.SelectedValue);

                    group.GroupType = entities.GroupTypes.FirstOrDefault(gt => gt.Id == gtype);

                    long followId = 0;
                    if (!string.IsNullOrWhiteSpace(atiRadComboBoxSearchGroups.SelectedValue))
                    {
                        followId = Convert.ToInt64(atiRadComboBoxSearchGroups.SelectedValue);

                    }
                    // first check if the group is following any other group;
                    UserFriends follow = entities.UserFriends.FirstOrDefault(f => f.SrcUserSettingKey == group.Id && f.Relationship == (int)Affine.Utils.ConstsUtil.Relationships.FOLLOW);
                    if (follow != null)
                    {
                        // make sure it is a valid group ..
                        Group test = entities.UserSettings.OfType<Group>().FirstOrDefault(g => g.Id == followId);
                        // just update the follow refrence ...
                        if (test != null)
                        {
                            follow.DestUserSettingKey = followId;
                        }
                    }
                    else
                    {
                        // make sure it is a valid group ..
                        Group test = entities.UserSettings.OfType<Group>().FirstOrDefault(g => g.Id == followId);
                        // just update the follow refrence ...
                        if (test != null)
                        {
                            UserFriends followGroup = new UserFriends()
                            {
                                SrcUserSettingKey = group.Id,
                                DestUserSettingKey = test.Id,
                                Relationship = (int)Affine.Utils.ConstsUtil.Relationships.FOLLOW
                            };
                            entities.AddToUserFriends(followGroup);
                        }
                    }

                    #region WebLinks settings
                    UserSettingsExtended[] webLinks = group.UserSettingsExtendeds.Where(s => s.Class == 1).ToArray();
                    if (atiWebLinks.Visible)
                    {
                        // Facebook
                        UserSettingsExtended facebook = webLinks.FirstOrDefault(s => s.Name == "Facebook");
                        if (!string.IsNullOrEmpty(atiWebLinks.Facebook))
                        {
                            if (facebook == null)
                            {
                                facebook = new UserSettingsExtended()
                                {
                                    Class = 1,
                                    Name = "Facebook",
                                    Value = atiWebLinks.Facebook
                                };
                                group.UserSettingsExtendeds.Add(facebook);
                            }
                            else
                            {
                                facebook.Value = atiWebLinks.Facebook;
                            }
                        }
                        else if (facebook != null)
                        {
                            entities.DeleteObject(facebook);
                        }

                        // Twitter
                        UserSettingsExtended twitter = webLinks.FirstOrDefault(s => s.Name == "Twitter");
                        if (!string.IsNullOrEmpty(atiWebLinks.Twitter))
                        {
                            if (twitter == null)
                            {
                                twitter = new UserSettingsExtended()
                                {
                                    Class = 1,
                                    Name = "Twitter",
                                    Value = atiWebLinks.Twitter
                                };
                                group.UserSettingsExtendeds.Add(twitter);
                            }
                            else
                            {
                                twitter.Value = atiWebLinks.Twitter;
                            }
                        }
                        else if (twitter != null)
                        {
                            entities.DeleteObject(twitter);
                        }

                        // YouTube
                        UserSettingsExtended youtube = webLinks.FirstOrDefault(s => s.Name == "YouTube");
                        if (!string.IsNullOrEmpty(atiWebLinks.YouTube))
                        {

                            if (youtube == null)
                            {
                                youtube = new UserSettingsExtended()
                                {
                                    Class = 1,
                                    Name = "YouTube",
                                    Value = atiWebLinks.YouTube
                                };
                                group.UserSettingsExtendeds.Add(youtube);
                            }
                            else
                            {
                                youtube.Value = atiWebLinks.YouTube;
                            }
                        }
                        else if (youtube != null)
                        {
                            entities.DeleteObject(youtube);
                        }

                        // LinkedIn
                        UserSettingsExtended linkedin = webLinks.FirstOrDefault(s => s.Name == "LinkedIn");
                        if (!string.IsNullOrEmpty(atiWebLinks.LinkedIn))
                        {
                            if (linkedin == null)
                            {
                                linkedin = new UserSettingsExtended()
                                {
                                    Class = 1,
                                    Name = "LinkedIn",
                                    Value = atiWebLinks.LinkedIn
                                };
                                group.UserSettingsExtendeds.Add(linkedin);
                            }
                            else
                            {
                                linkedin.Value = atiWebLinks.LinkedIn;
                            }
                        }
                        else if (linkedin != null)
                        {
                            entities.DeleteObject(linkedin);
                        }

                        // Flickr
                        UserSettingsExtended flickr = webLinks.FirstOrDefault(s => s.Name == "Flickr");
                        if (!string.IsNullOrEmpty(atiWebLinks.Flickr))
                        {
                            if (flickr == null)
                            {
                                flickr = new UserSettingsExtended()
                                {
                                    Class = 1,
                                    Name = "Flickr",
                                    Value = atiWebLinks.Flickr
                                };
                                group.UserSettingsExtendeds.Add(flickr);
                            }
                            else
                            {
                                flickr.Value = atiWebLinks.Flickr;
                            }
                        }
                        else if (flickr != null)
                        {
                            entities.DeleteObject(flickr);
                        }

                        // Personal
                        UserSettingsExtended personal = webLinks.FirstOrDefault(s => s.Name == "Personal");
                        if (!string.IsNullOrEmpty(atiWebLinks.Peronsal))
                        {
                            if (personal == null)
                            {
                                personal = new UserSettingsExtended()
                                {
                                    Class = 1,
                                    Name = "Personal",
                                    Value = atiWebLinks.Peronsal
                                };
                                group.UserSettingsExtendeds.Add(personal);
                            }
                            else
                            {
                                personal.Value = atiWebLinks.Peronsal;
                            }
                        }
                        else if (personal != null)
                        {
                            entities.DeleteObject(personal);
                        }

                    }
                    #endregion

                    UploadThemeBackground();
                    group.CssStyle = string.Empty;

                    if( !atiThemeEditor.BackgroundColor.IsEmpty )
                    {
                        group.CssStyle += "background-color: #" + atiThemeEditor.BackgroundColor.Name.Substring(2)+";";
                    }
                    if (atiThemeEditor.IsTiled)
                    {
                        group.CssStyle += "background-repeat: repeat;";
                    }else{
                        group.CssStyle += "background-repeat:no-repeat; background-attachment:fixed;";
                    }
                    this.BackgroundImageUrl = ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?u=" + group.UserKey + "&p=" + group.PortalKey + "&bg=1";
                    this.ProfileCSS = group.CssStyle;

                    entities.SaveChanges();

                    // Next the member list
                    Affine.WebService.StreamService ss = new WebService.StreamService();
                    string json = ss.getMemberListDataOfRelationship(GroupSettings.Id, (int)Affine.Utils.ConstsUtil.Relationships.GROUP_ADMIN, 0, 10);
                    string json2 = ss.getMemberListDataOfRelationship(GroupSettings.Id, (int)Affine.Utils.ConstsUtil.Relationships.GROUP_MEMBER, 0, 25);
                    RadAjaxManager1.ResponseScripts.Add(" $(function(){ Aqufit.Page.atiMemberListAdmin.generateStreamDom('" + json + "');  Aqufit.Page.atiMemberList.generateStreamDom('" + json2 + "');  }); ");
                }
                catch (Exception ex)
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\""+ex.Message.Replace("'","")+"\"}');");
                }

            }
            else
            {
                RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"\"}');");
            }
        }
Пример #32
0
        private bool RegisterGroup()
        {
            if (Page.IsValid)
            {
                // check required fields
                aqufitEntities entities = new aqufitEntities();
                Group test = entities.UserSettings.OfType<Group>().FirstOrDefault(g => g.UserName == atiGroupName.Text);
                // if a user is found with that username, error. this prevents you from adding a username with the same name as a superuser.
                if (test != null)
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"We already have an entry for the Group Name.\"}');");
                    return false;
                }
                Affine.WebService.RegisterService regService = new WebService.RegisterService();

                string fname = string.Empty;
                string lname = string.Empty;
                string pass = Guid.NewGuid().ToString();

                Group us = new Data.Group();
                us.UserKey = 0;
                us.PortalKey = PortalId;
                us.UserEmail = atiTxtGroupEmail.Text;
                us.UserName = atiGroupName.Text;
                us.UserFirstName = atiGroupName.Text;
                us.UserLastName = "";
                us.DefaultMapLat = atiAddress.Lat;
                us.DefaultMapLng = atiAddress.Lng;
                us.LngHome = atiAddress.Lat;
                us.LngHome = atiAddress.Lng;
                int gtype = Convert.ToInt32(ddlGroupType.SelectedValue);
                us.GroupType = entities.GroupTypes.FirstOrDefault(gt => gt.Id == gtype);

                us.Places.Add(new Place()
                {
                    City = atiAddress.City,
                    Country = atiAddress.Country,
                    Email = atiTxtGroupEmail.Text,
                    Lat = atiAddress.Lat,
                    Lng = atiAddress.Lng,
                    Name = atiGroupName.Text,
                    Postal = atiAddress.Postal,
                    Region = atiAddress.Region,
                    Street = atiAddress.Street
                });
                entities.AddToUserSettings(us);
                entities.SaveChanges();
                // Now assign the creator of the group as an admin
                Group group = entities.UserSettings.OfType<Group>().First(g => g.UserName == us.UserName);
                UserFriends uToG = new UserFriends()
                {
                    SrcUserSettingKey = UserSettings.Id,
                    DestUserSettingKey = group.Id,
                    Relationship = (short)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER
                };
                entities.AddToUserFriends(uToG);
                entities.SaveChanges();
                Response.Redirect(ResolveUrl("~") + "group/" + group.UserName + "/settings", true);
            }
            else
            {
                RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"\"}');");
            }
            return true;
        }
Пример #33
0
        public static MsCrmResultObject SearchContact(Guid portalId, Guid userId, string key, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT DISTINCT
                                        u.new_userId AS UserId
                                        ,u.new_name AS UserName
                                        ,u.new_imageurl AS ImageUrl
                                        ,c.FullName
                                        ,c.JobTitle
                                        ,CASE WHEN fr.new_friendshipId IS NOT NULL THEN 1 ELSE 0 END AS IsFriend
                                    FROM
                                    new_user AS u (NOLOCK)
                                        JOIN
                                            new_new_user_new_role AS ur (NOLOCK)
                                                ON
                                                ur.new_userid=u.new_userId
                                        JOIN
                                            new_role AS r (NOLOCK)
                                                ON
                                                ur.new_roleid=r.new_roleId
                                                AND
                                                r.statecode=0
                                                AND
                                                r.statuscode=1 --Active
                                                AND
                                                r.new_portalId='{0}'
                                        JOIN
                                            Contact AS c (NOLOCK)
                                                ON
                                                u.new_contactId=c.ContactId
                                        LEFT JOIN
                                            new_friendship AS fr (NOLOCK)
                                                ON
                                                '{2}' IN (fr.new_partyOneId,fr.new_partyTwoId)
                                                AND
                                                u.new_userId IN (fr.new_partyOneId,fr.new_partyTwoId)
                                                AND
                                                fr.statecode=0
                                    WHERE
                                        u.statecode=0
                                    AND
                                        u.new_userId!='{2}'
                                    AND
                                        u.statuscode=1 --Active
                                    AND
                                        c.FullName LIKE '%{1}%'";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, key, userId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    List<UserFriends> lstUser = new List<UserFriends>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        UserFriends uf = new UserFriends()
                        {
                            UserId = (Guid)dt.Rows[i]["UserId"],
                            UserName = dt.Rows[i]["UserName"].ToString(),
                            FullName = dt.Rows[i]["FullName"].ToString(),
                            ImageUrl = dt.Rows[i]["ImageUrl"] != DBNull.Value ? dt.Rows[i]["ImageUrl"].ToString() : "nouserprofile.jpg",
                            JobTitle = dt.Rows[i]["JobTitle"] != DBNull.Value ? dt.Rows[i]["JobTitle"].ToString() : "---",
                            UserType = (int)dt.Rows[i]["IsFriend"]
                        };

                        lstUser.Add(uf);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = lstUser;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M057"; //"Herhangi bir kayıt bulunamadı!";
                }

            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Пример #34
0
        public string FollowUser(long UserSettingsId, long fid)
        {
            // ok so the user has accepted the friend request. ( Followed user is always DestUserKey )
            // 1) Lets add the user to the firends
            aqufitEntities entities = new aqufitEntities();
            // Make sure that this not the same user
            if (UserSettingsId == fid)
            {
                return "{ 'status':'invalid' }";
            }
            // make sure it is not already in the db
            UserSettings you = entities.UserSettings.FirstOrDefault(s => s.Id == UserSettingsId);
            UserSettings friend = entities.UserSettings.FirstOrDefault(s => s.Id == fid );
            // check if they are already friends or in the watch list
            UserFriends uf = entities.UserFriends.FirstOrDefault(f => f.SrcUserSettingKey == UserSettingsId && f.DestUserSettingKey == fid || f.SrcUserSettingKey == fid && f.DestUserSettingKey == UserSettingsId);
            if (uf != null && uf.Relationship == (int)Affine.Utils.ConstsUtil.Relationships.FRIEND )
            {   // you can not "follow" your friends...
                return "{ 'status':'invalid' }";
            }
            else if (uf != null && uf.SrcUserSettingKey == UserSettingsId && uf.Relationship == (int)Affine.Utils.ConstsUtil.Relationships.FOLLOW)
            {   // you are already following...
                throw new Exception("You are already following this user.");
            }
            UserFriends uf2 = new UserFriends()
            {
                SrcUserSettingKey = you.Id,
                DestUserSettingKey = friend.Id,
                PortalKey = you.PortalKey,
                Relationship = (int)Affine.Utils.ConstsUtil.Relationships.FOLLOW
            };
            entities.AddToUserFriends(uf2);
            entities.SaveChanges();

            // Add the Num people you follow metric
            Metric met = entities.Metrics.FirstOrDefault(m => m.UserSetting.Id == you.Id && m.MetricType == (int)Affine.Utils.MetricUtil.MetricType.NUM_YOU_FOLLOW);
            if (met != null)
            {
                met.MetricValue = "" + (Convert.ToInt32(met.MetricValue) + 1);
            }
            else
            {
                met = new Metric()
                {
                    MetricType = (int)Affine.Utils.MetricUtil.MetricType.NUM_YOU_FOLLOW,
                    MetricValue = "1",
                    UserSetting = you
                };
                entities.AddToMetrics(met);
            }
            // Add the Number of follwers to the other user metric
            Metric met2 = entities.Metrics.FirstOrDefault(m => m.UserSetting.Id == friend.Id && m.MetricType == (int)Affine.Utils.MetricUtil.MetricType.NUM_FOLLOWERS);
            if (met2 != null)
            {
                met2.MetricValue = "" + (Convert.ToInt32(met2.MetricValue) + 1);
            }
            else
            {
                met2 = new Metric()
                {
                    MetricType = (int)Affine.Utils.MetricUtil.MetricType.NUM_FOLLOWERS,
                    MetricValue = "1",
                    UserSetting = friend
                };
                entities.AddToMetrics(met2);
            }
            entities.SaveChanges();

            // TODO:
            //sendUserFollowEmailAsync(src, dst);

            return "{ 'status':'success' }";
        }
Пример #35
0
        public static MsCrmResultObject GetUserFriendList(Guid portalId, Guid portalUserId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"--ARKADAŞLARIM
                                    SELECT
                                        u.new_userId AS UserId
                                        ,u.new_name AS UserName
                                        ,u.new_imageurl AS ImageUrl
                                        ,c.FullName
                                        ,A.UserType
                                        ,c.JobTitle
                                    FROM
                                    (
                                        SELECT
                                            CASE
                                                WHEN
                                                    f.new_partyoneId!='{1}'
                                                THEN
                                                    f.new_partyoneId
                                                ELSE
                                                    f.new_partytwoId
                                            END  AS UserId
                                            ,1 AS UserType
                                        FROM
                                            new_friendship AS f (NOLOCK)
                                        WHERE
                                            f.new_portalId='{0}'
                                        AND
                                            f.statecode=0
                                        AND
                                        (
                                            f.new_partyoneId='{1}' OR f.new_partytwoId='{1}'
                                        )

                                        UNION ALL

                                        SELECT
                                            r.new_touserId AS UserId
                                            ,2 AS UserType
                                        FROM
                                            new_friendshiprequest AS r (NOLOCK)
                                        WHERE
                                            r.new_portalId='{0}'
                                        AND
                                            r.statecode=0
                                        AND
                                            r.new_fromuserId='{1}'

                                        UNION ALL

                                        SELECT
                                            r.new_fromuserId AS UserId
                                            ,3 AS UserType
                                        FROM
                                            new_friendshiprequest AS r (NOLOCK)
                                        WHERE
                                            r.new_portalId='{0}'
                                        AND
                                            r.statecode=0
                                        AND
                                            r.new_touserId='{1}'

                                    ) AS A
                                        JOIN
                                            new_user AS u (NOLOCK)
                                                ON
                                                u.new_userId=A.UserId
                                                AND
                                                u.statecode=0
                                                AND
                                                u.statuscode=1 --Active
                                        JOIN
                                            Contact AS c (NOLOCK)
                                                ON
                                                c.ContactId=u.new_contactId";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, portalUserId));
                if (dt != null && dt.Rows.Count > 0)
                {
                    List<UserFriends> lstUser = new List<UserFriends>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        UserFriends uf = new UserFriends()
                        {
                            UserId = (Guid)dt.Rows[i]["UserId"],
                            UserName = dt.Rows[i]["UserName"].ToString(),
                            FullName = dt.Rows[i]["FullName"].ToString(),
                            UserType = Convert.ToInt32(dt.Rows[i]["UserType"]),
                            ImageUrl = dt.Rows[i]["ImageUrl"] != DBNull.Value ? dt.Rows[i]["ImageUrl"].ToString() : "nouserprofile.jpg",
                            JobTitle = dt.Rows[i]["JobTitle"] != DBNull.Value ? dt.Rows[i]["JobTitle"].ToString() : "---"
                        };

                        lstUser.Add(uf);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = lstUser;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M045"; //"Harhangi bir arkadaşlık işleminiz yok!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }