Esempio n. 1
0
        bool FieldChecker(SecureString[] values)
        {
            string temp;

            if ((temp = ValidateUserData.ValidateUserName(UserName, true)) != null)
            {
                ErrorMessage = temp;
                FieldState   = ControlStates.UserNameError;
                return(false);
            }

            if ((temp = ValidateUserData.ValidateEmail(Email, true)) != null)
            {
                FieldState   = ControlStates.EmailError;
                ErrorMessage = temp;
                return(false);
            }

            if ((temp = ValidateUserData.ValidatePassword(values, true)) != null)
            {
                FieldState   = ControlStates.PasswordError;
                ErrorMessage = temp;
                return(false);
            }

            ErrorMessage = "";
            FieldState   = ControlStates.NormalGray;
            return(true);
        }
Esempio n. 2
0
        async void createGroup(object objects)
        {
            var groupName = (string)((object[])objects)[0];
            var isPrivate = (bool)((object[])objects)[1];
            var isPublic  = (bool)((object[])objects)[2];
            var isChat    = (bool)((object[])objects)[3];
            var isChannel = (bool)((object[])objects)[4];

            string temp;

            if ((temp = ValidateUserData.ValidateUserName(groupName, true)) != null)
            {
                CreateGroupErrorMessage = temp;
                FieldState = ControlStates.GroupName;
                return;
            }

            //If chat accessability isn't specified
            if (!isPublic && !isPrivate)
            {
                CreateGroupErrorMessage = "Chat accessability isn't specified";
                FieldState = ControlStates.AccessabilityError;
                return;
            }

            //If chat type isn't specified
            if (!isChat && !isChannel)
            {
                CreateGroupErrorMessage = "Chat type isn't specified";
                FieldState = ControlStates.ChatType;
                return;
            }

            await UnitOfWork.CreateGroup(new Group(isPrivate, groupName, isChannel, "", 0, new List <int>()
            {
                UnitOfWork.User.Id
            }, new List <int>()
            {
                UnitOfWork.User.Id
            }, 1));

            ApplicationService.ChangeCurrentChat(UnitOfWork.Database.GroupsTableRepo.GetLast());
            ApplicationService.ChangeCurrentChatPage(Pages.ChatPages.Chat);

            CreateGroupErrorMessage = "";
            FieldState = ControlStates.NormalGray;
        }
Esempio n. 3
0
        void changeGroupInfo(object data)
        {
            var groupName = (((object[])data)[0] as string);
            var isPrivate = (bool)((object[])data)[1];
            var isChat    = (bool)((object[])data)[2];

            bool update = false;

            //Validate data

            if (ValidateUserData.ValidateUserName(groupName, false) != null)
            {
                ChangeGroupInfoErrorMessage = "Wrong group name";
                FieldState = ControlStates.UserNameError;
                return;
            }
            else
            {
                if (groupName == null)
                {
                    groupName = GroupInfo.Name;
                }
                else
                {
                    update = true;
                }
            }

            if (IsPrivate != isPrivate)
            {
                update = true;
            }

            if (IsChat != isChat)
            {
                update = true;
            }

            if (update)
            {
                UnitOfWork.ChangeGroupInfo(new Group(isPrivate, groupName, !isChat, GroupInfo.Image, GroupInfo.Id, GroupInfo.AdminsIdList, GroupInfo.MembersIdList, GroupInfo.UsersOnline));
            }

            ChangeGroupInfoErrorMessage = "";
            FieldState = ControlStates.NormalGray;
        }
Esempio n. 4
0
        async void changeUserInfo(object objects)
        {
            var data  = (object[])objects;
            var name  = (string)data[0];
            var email = (string)data[1];
            var bio   = (string)data[2];

            string temp;


            //Check and change user name
            if (name != String.Empty)
            {
                if ((temp = ValidateUserData.ValidateUserName(name, false)) != null)
                {
                    ChangeUserInfoErrorMessage = temp;
                    FieldState = ControlStates.UserNameError;
                    return;
                }
            }
            else
            {
                name = UnitOfWork.User.UserName;
            }


            //Check user email
            if (email != String.Empty)
            {
                if ((temp = ValidateUserData.ValidateEmail(email, false)) != null)
                {
                    ChangeUserInfoErrorMessage = temp;
                    FieldState = ControlStates.EmailError;
                    return;
                }
            }
            else
            {
                email = UnitOfWork.User.Email;
            }

            //Check Bio
            if (bio != String.Empty)
            {
                //Delate excess spaces
                bio = System.Text.RegularExpressions.Regex.Replace(bio, @"^(\s*)(\S*)(\s*)$", "$2");
            }
            else
            {
                bio = UnitOfWork.User.Bio;
            }

            //Make request to server
            var errorMess = await UnitOfWork.ChangeUserInfo(new User(name, UnitOfWork.User.Password, email, bio, UnitOfWork.User.ProfilePhoto, "true", UnitOfWork.User.chatsIdList, UnitOfWork.User.contactsIdList, UnitOfWork.User.Id));

            if (errorMess != null)
            {
                ChangeUserInfoErrorMessage = errorMess;
            }

            FieldState = ControlStates.NormalGray;
            ChangeUserInfoErrorMessage = "";
        }