示例#1
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)
                });
            }
        }
示例#2
0
        public MethodInvokeResult Login(string Username, string Password)
        {
            try
            {
                ValidationController.Prepare();

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

                Password.RequiredArgument("Password").NotNull().Between(8, 45);

                ValidationController.Validate(); //throw ValidateException

                return(unc.Login(Username, MD5Encrypt.Hash(Password)));
            }
            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)
                });
            }
        }
示例#3
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)
                });
            }
        }