Example #1
0
 public UserModel(string loginname, UserNames user)
 {
     loginName   = loginname;
     name        = user;
     preferences = new Preferences()
     {
         currency = "ZAR",
         locale   = "en_ZA"
     };
 }
Example #2
0
        private async Task <ReturnModel> Register(string userId, string collectionsId)
        {
            YodleeAuthReturn auth = await GetAdminAuth();

            ReturnModel returnModel = new ReturnModel();

            if (auth.token.accessToken != null)
            {
                YodleeModel yodleeModel = new YodleeModel();
                if (!Check(collectionsId))
                {
                    yodleeModel = new YodleeModel(collectionsId, "New");
                }
                else
                {
                    yodleeModel = new YodleeModel(collectionsId, "Get");
                }
                AspNetUsers   user          = new AspNetUsers();
                UserNames     userNames     = user.getNames(userId);
                RegisterModel registerModel = new RegisterModel(yodleeModel.loginName, userNames);

                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("Api-Version", "1.1");
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", auth.token.accessToken);
                StringContent       content  = new StringContent(JsonConvert.SerializeObject(registerModel), Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync(url + "/auth/register", content);

                if (response.IsSuccessStatusCode)
                {
                    YodleeAuthReturn authReturn = new YodleeAuthReturn();
                    authReturn = await authReturn.GetToken(yodleeModel.loginName);

                    returnModel.result    = true;
                    returnModel.returnStr = authReturn.token.accessToken;
                }
                else
                {
                    string tokenStr = await response.Content.ReadAsStringAsync();

                    ExceptionCatcher exceptionCatcher = new ExceptionCatcher();
                    exceptionCatcher.Catch(tokenStr);
                    returnModel.result = false;
                }
            }
            else
            {
                ExceptionCatcher catcher = new ExceptionCatcher();
                catcher.Catch("No Token generated");
                returnModel.result = false;
            }
            return(returnModel);
        }
Example #3
0
 public RegisterModel(string loginname, UserNames userN)
 {
     user = new UserModel(loginname, userN);
 }