public void OnPost() { string Parameter; bool confirm; ABCCS systemControl = new ABCCS(); Parameter = SearchParameter; string[] subs = Submit.Split(' '); switch (subs[0]) { case "Search": _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); // Message = $"OnPost - First - {FirstInputField}"; break; case "Delete": confirm = systemControl.DeleteAnItem(subs[1]); if (confirm) { Message = $"{subs[1]} deleted"; _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); } else { Message = "Error"; } break; default: break; } }
public void OnPost() { string Parameter; bool confirm; ABCCS systemControl = new ABCCS(); Parameter = SearchParameter; string[] subs = Submit.Split(' '); switch (subs[0]) { case "Search": _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); // Message = $"OnPost - First - {FirstInputField}"; break; case "Select": Item item = new Item(); item = systemControl.GetAnItem(subs[1]); ItemCodeField = item.ItemCode; ItemDescriptionField = item.ItemDescription; QuantityOnHandField = item.QuantityOnHand; UnitPriceField = item.UnitPrice; Message = $"{subs[1]} selected"; _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); break; case "Update": Item item2 = new Item() { ItemCode = ItemCodeField, ItemDescription = ItemDescriptionField, QuantityOnHand = QuantityOnHandField, UnitPrice = UnitPriceField }; try { confirm = systemControl.UpdateAnItem(item2); Message = $"{item2.ItemCode} updated : {confirm}"; } catch (Exception e) { Message = $"Error {e}"; throw; } break; default: break; } }
public void OnPost() { string Parameter; bool confirm; ABCCS systemControl = new ABCCS(); Parameter = SearchParameter; string[] subs = Submit.Split(' '); switch (subs[0]) { case "Search": _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); // Message = $"OnPost - First - {FirstInputField}"; items = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "items"); break; case "Add": try { _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); Item item = new Item(); item = systemControl.GetAnItem(subs[1]); items = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "items"); bool flag = false; foreach (var i in items) { if (item.ItemCode == i.ItemCode) { flag = true; } } if (flag == false) { items.Add(item); SessionHelper.SetObjectAsJson(HttpContext.Session, "items", items); Message = $"{subs[1]} added"; } else { Message = $"{subs[1]} already exists in the cart"; } } catch (Exception e) { Message = $"Error {e}"; } break; case "Remove": try { _sampleObjectCollection = systemControl.SearchItemsByParam(Parameter); Item item = new Item(); item = systemControl.GetAnItem(subs[1]); items = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "items"); var itemToRemove = items.Single(r => r.ItemCode == subs[1]); items.Remove(itemToRemove); SessionHelper.SetObjectAsJson(HttpContext.Session, "items", items); Message = $"{subs[1]} removed"; } catch (Exception e) { Message = $"Error {e}"; } break; case "CheckOut": break; default: break; } }