コード例 #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)));
        }
コード例 #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();
        }
コード例 #3
0
ファイル: ApiCore.cs プロジェクト: Paraldin/MCFin
        //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);
            }
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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());
            }
        }
コード例 #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);
        }
コード例 #8
0
 public AccountProvider(PostAccount postAccount)
 {
     this.postAcocunt = postAccount;
     dbAccount        = new DbAccount();
 }