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 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)); }