Exemplo n.º 1
0
        public async Task <IHttpActionResult> PutStorage(Guid id, ShopitemViewModel storage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != storage.Id)
            {
                return(BadRequest());
            }
            storage.Id = id;
            try
            {
                await _shopitemRepository.EditAsync(storage.ToModel());
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StorageExist(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        private void MButtonAdd_Click(object sender, EventArgs e)
        {
            mProgressBar.Visibility = Android.Views.ViewStates.Visible;
            ShopitemViewModel newShopList = new ShopitemViewModel()
            {
                ItemName    = Name.Text,
                Quantity    = int.Parse(Quantity.Text),
                ShoplistId  = ShopListFragment.mSelectedShopList.Id,
                AddedUserId = LoginPageActivity.StaticUserClass.ID.ToString()
            };

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

                if (isAdded)
                {
                    LoginPageActivity.mGlobalShopItem = await mShopItemDataService.GetAll();
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "ShopList Added", ToastLength.Long).Show());
                    mProgressBar.Visibility = Android.Views.ViewStates.Invisible;
                    ReplaceFragment(new ShopItemsFragment(), "Manage ShopLists");
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                }
            })).Start();
        }
Exemplo n.º 3
0
        public IHttpActionResult GetStorage(Guid id)
        {
            ShopitemViewModel storage = new ShopitemViewModel(_shopitemRepository.GetSingle(e => e.Id == id));

            if (storage == null)
            {
                return(NotFound());
            }

            return(Ok(storage));
        }
Exemplo n.º 4
0
        private void OnStorageClicked(object sender, int e)
        {
            mSelected         = e;
            mSelectedShopItem = mShopItems[mSelected];

            FragmentTransaction   transaction     = FragmentManager.BeginTransaction();
            DialogShopItemOptions ShopItemsDialog = new DialogShopItemOptions();

            ShopItemsDialog.Show(transaction, "dialogue fragment");
            ShopItemsDialog.OnShopItemOptionPicked += ShopItemOptions_OnComplete;
        }
Exemplo n.º 5
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (holder is ViewHolder vh)
            {
                ShopitemViewModel sl = this.mShopItem[position];
                vh.Name.Text     = sl.ItemName;
                vh.Quantity.Text = sl.Quantity.ToString();

                vh.ItemView.Selected = (mSelectedPosition == position);
            }
        }
Exemplo n.º 6
0
        public IHttpActionResult PostStorage(ShopitemViewModel storage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                _shopitemRepository.Add(storage.ToModel());
            }
            catch (DbUpdateException)
            {
                if (StorageExist(storage.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = storage.Id }, storage));
        }