Exemplo n.º 1
0
        private void AddStorageDialog_OnStorageAdd(object sender, OnAddStorageEventArgs e)
        {
            Storage newLoc = new Storage()
            {
                Name        = e.Name,
                Area        = e.Area,
                Description = e.Description,

                LocationId = LoginActivity.StaticLocationClass.Id
            };
            var progressDialog = ProgressDialog.Show(this, "Please wait...", "Adding Storage...", true);

            new Thread(new ThreadStart(delegate
            {
                var isAdded = mStorageDataService.Add(newLoc);
                var temp    = newLoc.Id.ToString();
                RunOnUiThread(() => progressDialog.Hide());

                if (isAdded)
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Storage Added", ToastLength.Long).Show());
                }
                else
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Failed to add, please check again form's field", ToastLength.Long).Show());
                }
            })).Start();
        }
Exemplo n.º 2
0
        private void MButtonAdd_Click(object sender, EventArgs e)
        {
            mProgressBar.Visibility = Android.Views.ViewStates.Visible;
            StorageViewModel newStorage = new StorageViewModel()
            {
                Name          = mStorageName.Text,
                Area          = mStorageArea.Text,
                Description   = mStorageDescription.Text,
                LocationId    = mSelectedLocationId,
                CreatedUserId = mAuthorizedId.ToString(),
                AddedUserId   = mAuthorizedId.ToString()
            };

            new Thread(new ThreadStart(async delegate
            {
                UpgradeProgress();
                var isAdded = mStorageDataService.Add(newStorage.ToModel());

                if (isAdded)
                {
                    LoginPageActivity.mGlobalStorages = await mStorageDataService.GetAll();
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Storage Added", ToastLength.Long).Show());
                    mProgressBar.Visibility = Android.Views.ViewStates.Invisible;
                    ReplaceFragment(new StoragesFragment(), "Manage Storages");
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                }
            })).Start();
        }