private void OnUseClicked(object sender, EventArgs e) { if (mSelectedInventoryClass.Id != null) { Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Used By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); UpgradeProgress(); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); mProgressBar.Visibility = Android.Views.ViewStates.Invisible; } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } }
public InventorylogViewModel(Inventorylog p) { this.AddedUserId = p.AddedUserId; this.LogDate = p.LogDate; this.InventoryId = p.InventoryId; this.Description = p.Description; this.Id = p.Id; }
public InventorylogViewModel(Inventorylog i) { this.Id = i.Id; this.AddedUserId = i.AddedUserId; this.CreatedDate = i.CreatedDate; this.LogDate = i.LogDate; this.Description = i.Description; this.InventoryId = i.InventoryId; }
//public bool Edit(Guid id, Inventorylog data) //{ // var content = new FormUrlEncodedContent(new[] // { // new KeyValuePair<string, string>("Price", data.Price.ToString()), // new KeyValuePair<string, string>("ExpDate", data.ExpirationDate.ToString()), // new KeyValuePair<string, string>("InventoryId", data.Id.ToString()), // }); // try // { // HttpResponseMessage resp = client.PutAsync(UrlHelper.Inventorylogs_Url + @"/PutInventory/" + id, content).Result; // Inventory t = JsonConvert.DeserializeObject<Inventory>(resp.Content.ReadAsStringAsync().Result); // return true; // } // catch // { // return false; // } //} public bool Delete(Guid id) { try { HttpResponseMessage resp = client.DeleteAsync(UrlHelper.Inventorylogs_Url + @"/DeleteInventory/" + id).Result; Inventorylog t = JsonConvert.DeserializeObject <Inventorylog>(resp.Content.ReadAsStringAsync().Result); return(true); } catch { return(false); } }
public async Task <IHttpActionResult> DeleteInventory(Guid id) { Inventorylog inventory = _inventorylogRepository.GetSingle(e => e.Id == id); if (inventory == null) { return(NotFound()); } await _inventorylogRepository.DeleteAsync(inventory); return(Ok(inventory)); }
public bool ConsumeInv(Guid id, Inventorylog data) { var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("Description", "Consumed By " + data.AddedUserId), }); try { HttpResponseMessage resp = client.PutAsync(UrlHelper.Inventorylogs_Url + @"/PutInventory/" + id, content).Result; Inventory t = JsonConvert.DeserializeObject <Inventory>(resp.Content.ReadAsStringAsync().Result); return(true); } catch { return(false); } }
public bool Add(Inventorylog data) { var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("InventoryId", data.InventoryId.ToString()), new KeyValuePair <string, string>("CreatedDate", data.CreatedDate.ToString()), new KeyValuePair <string, string>("LogDate", data.LogDate.ToString()), new KeyValuePair <string, string>("Description", data.Description.ToString()), new KeyValuePair <string, string>("AddedUserId", data.AddedUserId.ToString()) }); try { HttpResponseMessage resp = client.PostAsync(UrlHelper.Inventorylogs_Url + @"/PostInventory", content).Result; Inventory t = JsonConvert.DeserializeObject <Inventory>(resp.Content.ReadAsStringAsync().Result); return(true); } catch { return(false); } }
private void InventoryOptions_OnComplete(object sender, OnHomeInventoryDialogPicked e) { var menu = e.MenuItem; if (menu == 1) { if (mSelectedInventoryClass.Id != null) { Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Used By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); LoadInventoriesData(); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); ReplaceFragment(new InventoriesFragment(), "Manage Inventories"); } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } } else if (menu == 2) { if (mSelectedInventoryClass.Id != null) { Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Throwed By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); LoadInventoriesData(); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); ReplaceFragment(new InventoriesFragment(), "Manage Inventories"); } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } } else if (menu == 3) { if (mSelectedInventoryClass.Id != null) { Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Removed By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); LoadInventoriesData(); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } } else { } }