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)); }
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(); }
public IHttpActionResult GetStorage(Guid id) { ShopitemViewModel storage = new ShopitemViewModel(_shopitemRepository.GetSingle(e => e.Id == id)); if (storage == null) { return(NotFound()); } return(Ok(storage)); }
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; }
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); } }
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)); }