public bool Delete(int InventoryID) { bool Confirmation; InventoryDataController InventoryDataController = new InventoryDataController(); Confirmation = InventoryDataController.DeleteInventoryItem(InventoryID); return(Confirmation); }
public bool Put([FromBody] Inventory UpdatedInventory) { bool Confirmation; InventoryDataController InventoryDataController = new InventoryDataController(); Confirmation = InventoryDataController.UpdateInventoryItem(UpdatedInventory.InventoryID, UpdatedInventory.Quantity); return(Confirmation); }
public Inventory Get(int InventoryID) { Inventory InventoryItem = new Inventory(); InventoryDTO FoundInventoryItem = new InventoryDTO(); InventoryDataController InventoryDataController = new InventoryDataController(); FoundInventoryItem = InventoryDataController.GetInventoryItemByID(InventoryID); InventoryItem.InventoryID = FoundInventoryItem.InventoryID; InventoryItem.CardID = FoundInventoryItem.CardID; InventoryItem.SealedProductID = FoundInventoryItem.SealedProductID; InventoryItem.QualityID = FoundInventoryItem.QualityID; InventoryItem.Quantity = FoundInventoryItem.Quantity; InventoryItem.FirstEdition = FoundInventoryItem.FirstEdition; return(InventoryItem); }
public bool Post([FromBody] Inventory NewInventoryItem) { bool Confirmation; InventoryDTO NewItem = new InventoryDTO(); InventoryDataController InventoryDataController = new InventoryDataController(); //Idea 1: //Check first if the new item needs to even be added or to update instead //Doing this will need me to check if the Card/SealedProduct already has an ID in the database with the same quality rating and if it has a first edition as true or not //if it has none of those make a new one. if not update the exisitng record instead based on the inventory ID //Idea 2: //If there is an inventory ID then I dont save and instead update the quantity. Nothing else will or should get changed. NewItem.CardID = NewInventoryItem.CardID; NewItem.SealedProductID = NewInventoryItem.SealedProductID; NewItem.QualityID = NewInventoryItem.QualityID; NewItem.Quantity = NewInventoryItem.Quantity; NewItem.FirstEdition = NewInventoryItem.FirstEdition; Confirmation = InventoryDataController.AddNewInventoryItem(NewItem); return(Confirmation); }
public List <Inventory> Get() { List <Inventory> InventoryItems = new List <Inventory>(); List <InventoryDTO> InventoryDTOs = new List <InventoryDTO>(); InventoryDataController InventoryDataController = new InventoryDataController(); InventoryDTOs = InventoryDataController.GetAllInventoryItems(); foreach (var Item in InventoryDTOs) { Inventory FoundItem = new Inventory { InventoryID = Item.InventoryID, CardID = Item.CardID, SealedProductID = Item.SealedProductID, QualityID = Item.QualityID, Quantity = Item.Quantity, FirstEdition = Item.FirstEdition }; InventoryItems.Add(FoundItem); } return(InventoryItems); }
public static async Task <ComposeExtensionResponse> CreateResponse(Activity activity) { ComposeExtensionResponse response = null; var query = activity.GetComposeExtensionQueryData(); JObject data = activity.Value as JObject; //Check to make sure a query was actually made: if (query.CommandId == null || query.Parameters == null) { return(null); } else if (query.Parameters.Count > 0) { // query.Parameters has the parameters sent by client var results = new ComposeExtensionResult() { AttachmentLayout = "list", Type = "result", Attachments = new List <ComposeExtensionAttachment>(), }; if (query.CommandId == "searchInventory") { InventoryDataController inventoryDataController = new InventoryDataController(); IEnumerable <Inventory> inventories; if (query.Parameters[0].Name == "initialRun") { // Default query => list all inventories = inventoryDataController.ListInventory(10); } else { // Basic search. string title = query.Parameters[0].Value.ToString().ToLower(); inventories = inventoryDataController.ListInventory(10).Where(x => x.Title.ToLower().Contains(title)); } // Generate cards for the response. foreach (Inventory inv in inventories) { var card = CardHelper.CreateCardForInventory(inv, true); var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment(); results.Attachments.Add(composeExtensionAttachment); } } else if (query.CommandId == "searchSupplier") { SupplierDataController supplierDataController = new SupplierDataController(); IEnumerable <Supplier> suppliers; if (query.Parameters[0].Name == "initialRun") { // Default query => list all suppliers = supplierDataController.ListSupplier(10); } else { string title = query.Parameters[0].Value.ToString().ToLower(); suppliers = supplierDataController.ListSupplier(10).Where(x => x.Title.ToLower().Contains(title)); } foreach (Supplier sup in suppliers) { var card = CardHelper.CreateCardForSupplier(sup, true); var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment(); results.Attachments.Add(composeExtensionAttachment); } } response = new ComposeExtensionResponse() { ComposeExtension = results }; } return(response); }