Beispiel #1
0
        public MethodInvokeResult ChangeUserInfo(int UserID, String FirstName, String LastName, int QuestionID, String Answer, DateTime Birthdate)
        {
            try
            {
                ValidationController.Prepare();

                FirstName.RequiredArgument("FirstName").NotNull().Between(2, 45);
                LastName.RequiredArgument("LastName").NotNull().Between(2, 45);
                Answer.RequiredArgument("Answer").NotNull().Between(2, 50);
                QuestionID.RequiredArgumentWithStruct("QuestionID").BeginFrom(1);
                Birthdate.RequiredArgumentWithStruct("Birthdate").NotNull();

                ValidationController.Validate(); //throw ValidateException

                return(unc.ChangeUserInfo(UserID, FirstName, LastName, QuestionID, Answer, Birthdate));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #2
0
        public MethodInvokeResult MoveContact(int UserID, int FriendID, int NewGroupID)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);
                FriendID.RequiredArgumentWithStruct("FriendID").BeginFrom(1);
                NewGroupID.RequiredArgumentWithStruct("NewGroupID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.MoveContact(UserID, FriendID, NewGroupID));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #3
0
        public MethodInvokeResult AnswerIsMatch(int UserID, int QuestionID, String Answer)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);
                QuestionID.RequiredArgumentWithStruct("QuestionID").BeginFrom(1);
                Answer.RequiredArgument("ImageBytes")
                .NotNull()     //throw ArgumentNullException
                .Between(2, 50);

                ValidationController.Validate(); //throw ValidateException

                return(unc.AnswerIsMatch(UserID, QuestionID, Answer));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #4
0
        public MethodInvokeResult AddGroup(int UserID, String Name, ref int NewGroupID)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);
                Name.RequiredArgument("Name")
                .NotNull()     //throw ArgumentNullException
                .Between(1, 45);

                ValidationController.Validate(); //throw ValidateException

                return(unc.AddGroup(UserID, Name, ref NewGroupID));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #5
0
        public MethodInvokeResult UserExist(string Username)
        {
            try
            {
                ValidationController.Prepare();

                Username.RequiredArgument("Username")
                .NotNull()     //throw ArgumentNullException
                .Between(6, 45);

                ValidationController.Validate(); //throw ValidateException

                return(unc.UserExist(Username));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #6
0
        public MethodInvokeResult ChangeAvatar(int UserID, byte[] ImageBytes)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);
                ImageBytes.RequiredArgument("ImageBytes")
                .NotNull();                      //throw ArgumentNullException

                ValidationController.Validate(); //throw ValidateException

                return(unc.ChangeAvatar(UserID, ImageBytes));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #7
0
        public MethodInvokeResult MarkAsReadConversation(int ConversationID)
        {
            try
            {
                ValidationController.Prepare();

                ConversationID.RequiredArgumentWithStruct("UserID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.MarkAsReadConversation(ConversationID));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #8
0
        public MethodInvokeResult RemoveGroup(int GroupID, bool RemoveContact)
        {
            try
            {
                ValidationController.Prepare();

                GroupID.RequiredArgumentWithStruct("UserID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.RemoveGroup(GroupID, RemoveContact));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #9
0
        public Users FindName(String Username)
        {
            try
            {
                ValidationController.Prepare();

                Username.RequiredArgument("Username")
                .NotNull()     //throw ArgumentNullException
                .Between(6, 45);

                ValidationController.Validate(); //throw ValidateException

                return(unc.FindName(Username));
            }
            catch (ArgumentNullException)
            {
                return(null);
            }
            catch (ValidateException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #10
0
        public MethodInvokeResult SaveConversation(int UserID, int FriendID, String Content, DateTime Time, ref int ConversationID)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);
                FriendID.RequiredArgumentWithStruct("FriendID").BeginFrom(1);
                Content.RequiredArgument("Content").NotNull();  //throw ArgumentNullException
                Time.RequiredArgumentWithStruct("Time").NotNull();

                ValidationController.Validate(); //throw ValidateException

                return(unc.SaveConversation(UserID, FriendID, Content, Time, ref ConversationID));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #11
0
        public MethodInvokeResult AccountRecovery(int UserID, String NewPassword)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);

                NewPassword.RequiredArgument("NewPassword")
                .NotNull()     //throw ArgumentNullException
                .Between(8, 45);

                ValidationController.Validate(); //throw ValidateException

                return(unc.AccountRecovery(UserID, MD5Encrypt.Hash(NewPassword)));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #12
0
        public FriendGroup GroupInfo(int GroupID)
        {
            try
            {
                ValidationController.Prepare();

                GroupID.RequiredArgumentWithStruct("GroupID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.GroupInfo(GroupID));
            }
            catch (ValidateException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #13
0
        public GroupFriendList FriendList(int UserID)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.FriendList(UserID));
            }
            catch (ValidateException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #14
0
        public List <Users> UnresponseFriendRequests(int UserID)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.UnresponseFriendRequests(UserID));
            }
            catch (ValidateException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #15
0
        public List <Conversation> GetNewestConversations(int UserID)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.GetNewestConversations(UserID));
            }
            catch (ValidateException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #16
0
        public MethodInvokeResult Signup(string Username, string Password, string FirstName, string LastName, int QuestionID, string Answer, DateTime Birthdate)
        {
            try
            {
                ValidationController.Prepare();

                Username.RequiredArgument("Username")
                .NotNull()     //throw ArgumentNullException
                .Between(6, 45);

                Password.RequiredArgument("Password").NotNull().Between(8, 45);
                LastName.RequiredArgument("LastName").NotNull().Between(2, 45);
                FirstName.RequiredArgument("FirstName").NotNull().Between(2, 45);
                Answer.RequiredArgument("Answer").NotNull().Between(2, 50);
                Birthdate.RequiredArgumentWithStruct("Birthdate").NotNull();

                ValidationController.Validate(); //throw ValidateException

                return(unc.Signup(Username, MD5Encrypt.Hash(Password), FirstName, LastName, QuestionID, Answer, Birthdate));
            }
            catch (ValidateException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Errors = ex.Errors, Exception = new ExceptionInfo(ex)
                });
            }
            catch (ArgumentNullException ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.INPUT_ERROR, Message = ex.Message, Exception = new ExceptionInfo(ex)
                });
            }
            catch (Exception ex)
            {
                return(new MethodInvokeResult {
                    Status = MethodInvokeResult.RESULT.UNHANDLE_ERROR, Message = String.Format("Unhandle error occurs: {0}", ex.Message), Exception = new ExceptionInfo(ex)
                });
            }
        }
Beispiel #17
0
        public List <Conversation> GetConversations(int UserID, int BeginIndex, int EndIndex)
        {
            try
            {
                ValidationController.Prepare();

                UserID.RequiredArgumentWithStruct("UserID").BeginFrom(1);
                BeginIndex.RequiredArgumentWithStruct("BeginIndex").BeginFrom(1);
                BeginIndex.RequiredArgumentWithStruct("EndIndex").BeginFrom(1);

                ValidationController.Validate(); //throw ValidateException

                return(unc.GetConversations(UserID, BeginIndex, EndIndex));
            }
            catch (ValidateException)
            {
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }