Esempio n. 1
0
        public Task <CloudFlareResult <AccountMember> > AddAccountMemberAsync(string accountId, string emailAddress, IEnumerable <AccountRole> roles)
        {
            var addAccountMember = new PostAccount
            {
                EmailAddress = emailAddress,
                Roles        = roles,
                Status       = AddMembershipStatus.Pending
            };

            return(SendRequestAsync <AccountMember>(_httpClient.PostAsJsonAsync(
                                                        $"{ApiParameter.Endpoints.Account.Base}/{accountId}/{ApiParameter.Endpoints.Account.Members}", addAccountMember)));
        }
Esempio n. 2
0
        private async void submitButton_Clicked(object sender, EventArgs e)
        {
            var newAccount = new PostAccount
            {
                HHid           = Constants.APIConstants.HouseId,
                AccountName    = accountEntry.Text,
                AccountBalance = Convert.ToDecimal(balanceEntry.Text),
                CreatedById    = Constants.APIConstants.UserId,
                Warning        = Convert.ToDecimal(warningEntry.Text)
            };

            await ApiCore.PostAccount(newAccount);

            await Navigation.PopAsync();
        }
Esempio n. 3
0
        //Says post, but is a get
        public static async Task <Int16> PostAccount(PostAccount a)
        {
            string root        = APIConstants.Root;
            string queryString = $"{root}/api/Accounts/AddAccount?HHid={a.HHid}&accountName={a.AccountName}&accountBalance={a.AccountBalance}&createdById={a.CreatedById}&warning={a.Warning}";

            var jsonResult = await ApiServices.GetDataFromService(queryString).ConfigureAwait(false);

            if (jsonResult != null)
            {
                return(-1);
            }
            else
            {
                return(500);
            }
        }
Esempio n. 4
0
        internal static DbAccount map(PostAccount postAcocunt)
        {
            DataCrypt dataCrypt = new DataCrypt();

            if (postAcocunt != null)
            {
                return(new DbAccount()
                {
                    UserEmail = postAcocunt.UserEmail,
                    UserName = postAcocunt.UserName,
                    UserPassword = dataCrypt.Encrypt(postAcocunt.UserPassword),
                    UserCreatedOn = DateTime.Now
                });
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
        private Result AccountValidate(PostAccount account)
        {
            Result result = new Result();

            if (String.IsNullOrEmpty(account.UserEmail))
            {
                result.status = false;
                result.value  = "Pole " + nameof(account.UserEmail) + " musi być uzupełnione";
            }
            if (String.IsNullOrEmpty(account.UserName))
            {
                result.status = false;
                result.value  = "Pole " + nameof(account.UserName) + " musi być uzupełnione";
            }
            if (String.IsNullOrEmpty(account.UserPassword))
            {
                result.status = false;
                result.value  = "Pole " + nameof(account.UserPassword) + " musi być uzupełnione";
            }
            return(result);
        }
Esempio n. 6
0
        public ActionResult Create(PostAccount collection)
        {
            AccountProvider accountProvider = new AccountProvider();

            try
            {
                var result = accountProvider.CreateAccount(collection);
                if (result.status == true)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest(result));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }
Esempio n. 7
0
        public Result CreateAccount(PostAccount postAccount)
        {
            Result result = new Result();

            //walidacja pól
            if (this.postAcocunt != null)
            {
                result = AccountValidate(this.postAcocunt);
                if (!result.status)
                {
                    return(result);
                }
                else
                {
                    // sprawdzznie duplikatu
                    if (account.Get(postAcocunt.UserEmail) == null)
                    {
                        result.status = false;
                        result.value  = "Konto " + postAcocunt.UserEmail + " już istnieje !";
                        return(result);
                    }
                    else
                    {
                        this.dbAccount = ModeltoDtoAccoutMapper.map(postAcocunt);
                        // mapowanie pól
                        if (dbAccount != null)
                        {
                            account.Add(dbAccount);
                        }
                        else
                        {
                            result.status = false;
                            result.value  = "Błąd zapisu !";
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 8
0
 public AccountProvider(PostAccount postAccount)
 {
     this.postAcocunt = postAccount;
     dbAccount        = new DbAccount();
 }