private void MButtonAdd_Click(object sender, EventArgs e) { mProgressBar.Visibility = Android.Views.ViewStates.Visible; ShoplistViewModel newShopList = new ShoplistViewModel() { Name = mShopListName.Text, Description = mShopListDescription.Text, LocationId = LoginPageActivity.StaticActiveLocationClass.Id.ToString(), AddedUserId = LoginPageActivity.StaticUserClass.ID.ToString() }; new Thread(new ThreadStart(async delegate { UpgradeProgress(); var isAdded = shoplistDataService.Add(newShopList.ToModel()); if (isAdded) { LoginPageActivity.mGlobalShopList = await shoplistDataService.GetAll(); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "ShopList Added", ToastLength.Long).Show()); mProgressBar.Visibility = Android.Views.ViewStates.Invisible; ReplaceFragment(new ShopListFragment(), "Manage ShopLists"); } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); }
private void MButtonSave_Click(object sender, EventArgs e) { ShoplistViewModel newShopList = new ShoplistViewModel() { Name = mShopListName.Text, Description = mShopListDescription.Text, LocationId = LoginPageActivity.StaticActiveLocationClass.Id.ToString(), AddedUserId = LoginPageActivity.StaticUserClass.ID.ToString() }; new Thread(new ThreadStart(async delegate { var isAdded = shoplistDataService.Edit(ShopListFragment.mSelectedShopList.Id, newShopList.ToModel()); if (isAdded) { LoginPageActivity.mGlobalShopList = await shoplistDataService.GetAll(); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Success", ToastLength.Long).Show()); ReplaceFragment(new ShopListFragment(), "Manage ShopLists"); } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); }
public async Task <IHttpActionResult> PutShopList(Guid id, ShoplistViewModel storage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != storage.Id) { return(BadRequest()); } storage.Id = id; try { await _shoplistRepository.EditAsync(storage.ToModel()); } catch (DbUpdateConcurrencyException) { if (!StorageExist(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder is ViewHolder vh) { ShoplistViewModel sl = this.mShopList[position]; vh.ShopListName.Text = sl.Name; vh.ShopListDescription.Text = sl.Description; vh.ItemView.Selected = (mSelectedPosition == position); } }
private void OnShopListClicked(object sender, int e) { mSelected = e; mSelectedShopList = mShopLists[e]; FragmentTransaction transaction = FragmentManager.BeginTransaction(); DialogShopListOptions DialogShopList = new DialogShopListOptions(); DialogShopList.Show(transaction, "dialogue fragment"); DialogShopList.OnShopListOptionPicked += ShopListOptions_OnComplete; }
public IHttpActionResult GetShopList(Guid id) { ShoplistViewModel storage = new ShoplistViewModel(_shoplistRepository.GetSingle(e => e.Id == id)); if (storage == null) { return(NotFound()); } return(Ok(storage)); }
public IHttpActionResult PostShopList(ShoplistViewModel storage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _shoplistRepository.Add(storage.ToModel()); } catch (DbUpdateException) { if (StorageExist(storage.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = storage.Id }, storage)); }