예제 #1
0
        public Consultant RegisterPendingConsultant()
        {
            // consultant
            Consultant consultant = TestRepository.GetValidConsultant();
            var        task       = conService.RegisterConsultant(consultant);

            task.Wait();
            var responses = task.Result;

            Assert.True(responses.Select(r => r.Code == ApiResponseCode.RegisterSuccess).FirstOrDefault());
            return(consultant);
        }
예제 #2
0
        public async void PerformRegistration(Account account, string plainPassword)
        {
            // TODO
            // Check muna tru service kung existing
            // i believe nagrereturn sya ng errors pag existing
            // un nalang kunin, i-try catch natin

            // PASSWORD Pa pala
            // password service
            List <ApiResponse> responses     = null;
            List <ApiResponse> passResponses = null;

            if (account.AccTypeId == AccountType.Consultant)
            {
                responses = await conService.RegisterConsultant(new Consultant(account));

                passResponses = await passService.RegisterPassword(account.Username, plainPassword);
            }

            if (responses == null)
            {
                view.DisplayResponse("Error Occured", "There was an error processing the request");
                return;
            }

            bool success = responses.Select(resp => resp.Code == ApiResponseCode.RegisterSuccess).FirstOrDefault() &&
                           passResponses.Select(resp => resp.Code == ApiResponseCode.RegisterSuccess).FirstOrDefault();

            if (success)
            {
                ApiResponse response = responses.FirstOrDefault();
                view.DisplayResponse(response?.Subject, response?.ToString());
            }
            else
            {
                string subject = "Registration Not Successful";
                string message = "";

                for (int i = 0; i < responses.Count; i++)
                {
                    message += (i + 1) + ") " + responses[i] + "\n";
                }

                view.DisplayResponse(subject, message);
            }
        }
예제 #3
0
        public async void PerformRegistration(Account account, string plainPassword)
        {
            // TODO
            // Check muna tru service kung existing
            // i believe nagrereturn sya ng errors pag existing
            // un nalang kunin, i-try catch natin

            // PASSWORD Pa pala
            // password service
            List <ApiResponse> responses     = null;
            List <ApiResponse> passResponses = null;

            if (account.AccTypeId == AccountType.Consultant)
            {
                responses = await conService.RegisterConsultant(new Consultant(account));
            }
            else if (account.AccTypeId == AccountType.Client)
            {
                AccountSession conAccount = SessionFactory.ReadSession <AccountSession> (SessionKeys.LoginKey);
                if (conAccount.AccountType != AccountType.Consultant)
                {
                    return;
                }

                Consultant consultant = new Consultant()
                {
                    AccountId = conAccount.AccountId,
                    Username  = conAccount.Username,
                    AccTypeId = conAccount.AccountType
                };
                responses = await cliService.RegisterClientToConsultant(new Client (account), consultant);
            }

            if (responses == null)
            {
                //TODO UNG DISPLAY KO GAGO KA BA, GAWIN MO NA JHON PAUL JASPE UNG DISPLAY NETO OI MAMA MO
                view.DisplayResponse("Error Occured", "There was an error processing the request");
                return;
            }

            passResponses = await passService.RegisterPassword(account.Username, plainPassword);

            if (passResponses == null)
            {
                view.DisplayResponse("Error Occured", "There was an error processing the request");
                return;
            }

            bool success = responses.Select(resp => resp.Code == ApiResponseCode.RegisterSuccess).FirstOrDefault() &&
                           passResponses.Select(resp => resp.Code == ApiResponseCode.RegisterSuccess).FirstOrDefault();

            if (success)
            {
                ApiResponse response = responses.FirstOrDefault();
                view.DisplayResponse(response?.Subject, response?.ToString());
                view.FinishRegister();
            }
            else
            {
                string subject = "Registration Not Successful";
                string message = "";

                for (int i = 0; i < responses.Count; i++)
                {
                    message += (i + 1) + ") " + responses[i] + "\n";
                }

                view.DisplayResponse(subject, message);
            }
        }