Beispiel #1
0
        private async Task InsertOwner()
        {
            if (ValidateInputs())
            {
                OwnerInsertVM ownerInsertVM = new OwnerInsertVM()
                {
                    Username     = TbUsername.Text,
                    Password     = TbPassword.Password,
                    Email        = TbEmail.Text,
                    FirstName    = TbFirstName.Text,
                    LastName     = TbLastName.Text,
                    Pin          = TbPin.Text,
                    Subscription = (Subscription)CbSubscriptions.SelectedItem
                };

                ls.LblLoading.Text = "Adding";
                ls.Show();
                bool success = await ownerApi.InsertOwner(ownerInsertVM);

                ls.Close();

                if (success)
                {
                    Close();
                }
                else
                {
                    MessageBox.Show("Fail!");
                }
            }
            else
            {
                MessageBox.Show("All input fields are required and Password must match Confirm password!");
            }
        }
Beispiel #2
0
        public async Task <bool> InsertOwner(OwnerInsertVM ownerInsertVM)
        {
            StringContent       content  = GetStringContent(ownerInsertVM);
            HttpClient          request  = new HttpClient();
            HttpResponseMessage response = await request.PostAsync($"{ API_URL }/InsertOwner", content);

            if (response.IsSuccessStatusCode)
            {
                bool result = await response.Content.ReadAsAsync <bool>();

                return(result);
            }
            return(false);
        }
Beispiel #3
0
        public bool InsertOwner(OwnerInsertVM ownerInsertVM)
        {
            Password password = CreateHashedPasswordAndSalt(ownerInsertVM.Password);

            Subscription subscription = unitOfWork.Subscriptions.Get(ownerInsertVM.Subscription.Id);

            Owner owner = new Owner()
            {
                Username     = ownerInsertVM.Username,
                PasswordHash = password.Hash,
                PasswordSalt = password.Salt,
                FirstName    = ownerInsertVM.FirstName,
                LastName     = ownerInsertVM.LastName,
                Email        = ownerInsertVM.Email,
                Pin          = ownerInsertVM.Pin,
                Subscription = subscription
            };

            unitOfWork.Owners.Add(owner);

            int success = unitOfWork.Complete();

            return(success > 0);
        }