예제 #1
0
        public ClientJsonResult Register(UserRegistrationClient registerUser)
        {
            if (registerUser != null)
            {
                try
                {
                    registerUser.ClearNotifications();
                    IAccountDriver driver = DependencyResolver.Current.GetService<IAccountDriver>();
                    TokenUser tokenUser;
                    OperationStatus status = driver.TryRegister(registerUser, out tokenUser);
                    if (status == OperationStatus.RegisterSuccess)
                    {
                        SaveTicketToCookie(tokenUser, false);
                        TokenUserClient clientTokenUser = new TokenUserClient(tokenUser);
                        clientTokenUser.AddSuccessNotification(MessageManager.GetMessage(status));
                        return ClientJson(clientTokenUser);
                    }
                    else
                    {
                        registerUser.ServerStatus = false;
                        registerUser.AddErrorNotification(MessageManager.GetMessage(status));
                    }
                }
                catch (Exception ex)
                {
                    registerUser.ServerStatus = false;
                    LoggingWork.Error(ex);
                    registerUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.GenericError));
                }
            }
            else
            {
                registerUser = new UserRegistrationClient() { ServerStatus = false };
                registerUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.DataFormatError));
            }

            return ClientJson(registerUser);
        }
예제 #2
0
        public ClientJsonResult SignOut(TokenUserClient tokenUser)
        {
            
            if (tokenUser != null)
            {
                IAccountDriver driver = DependencyResolver.Current.GetService<IAccountDriver>();
                driver.TrySignOut(tokenUser);
                FormsAuthentication.SignOut();
                tokenUser.AddSuccessNotification(MessageManager.GetMessage(OperationStatus.SignOutSuccess));
            }
            else
            {
                tokenUser = new TokenUserClient();
                tokenUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.DataFormatError));
            }
            return ClientJson(tokenUser);

        }