public void UpdateCatalogueItem(CatalogueItemEF item) { if (item != null) { stockEFF.SaveCatalogueItem(item); } }
public ActionResult DeleteCatalogueItem(int catalogueId) { CatalogueItemEF item = stockService.FindCatalogueItemById(catalogueId); stockService.DeleteCatalogueItem(item); return(RedirectToAction("ViewCatalogue", new { page = 1 })); }
public void DeleteCatalogueItem(CatalogueItemEF item) { if (item != null) { stockEFF.RemoveFromCatalogue(item); } }
public void SaveCatalogueItem(CatalogueItemEF item) { var existingItem = context.CatalogueItems.Find(item.CatalogueId); if (existingItem != null) { context.Entry(existingItem).CurrentValues.SetValues(item); context.SaveChanges(); } }
public ActionResult CreateCatalogueItem(CatalogueItemDTO item) { //create catalogue item CatalogueItemEF catItem = new CatalogueItemEF() { ItemCode = item.ItemCode, ReorderLevel = item.ReorderLevel, ReorderQty = item.ReorderQty }; stockService.CreateCatalogueItem(catItem); return(RedirectToAction("ViewCatalogueItem", new { catalogueId = catItem.CatalogueId })); }
public ActionResult ViewCatalogueItem(int catalogueId) { CatalogueItemEF catItem = stockService.FindCatalogueItemById(catalogueId); if (catItem == null) { return(View("Error")); } ViewData["catItem"] = catItem; StaffEF staff = staffService.GetStaff(); ViewData["staff"] = staff; return(View()); }
public async Task <ActionResult> UpdateCatalogueItem(CatalogueItemDTO item, string decision) { if (decision == "Cancel") { return(RedirectToAction("ViewCatalogueItem", new { catalogueId = item.CatalogueId })); } if (decision == "Predict Reorder Quantity") { // get prediction from service using (var client = new HttpClient()) { PredictReorderQtyDTO predModel = predictService.GetPredictModel(item); // send a POST request to the server uri with the data and get the response as HttpResponseMessage object HttpResponseMessage res = await client.PostAsJsonAsync("http://127.0.0.1:5000/", predModel); // Return the result from the server if the status code is 200 (everything is OK) if (res.IsSuccessStatusCode) { int prediction = int.Parse(res.Content.ReadAsStringAsync().Result); ModelState.Remove("ReorderQty"); item.ReorderQty = prediction; } else { //set error message or view } // set it and throw it back to the update catalogue view return(View(item)); } } // decision == Save CatalogueItemEF catItem = new CatalogueItemEF() { CatalogueId = item.CatalogueId, ItemCode = item.ItemCode, ReorderLevel = item.ReorderLevel, ReorderQty = item.ReorderQty }; stockService.UpdateCatalogueItem(catItem); return(RedirectToAction("ViewCatalogueItem", new { catalogueId = catItem.CatalogueId })); }
public ActionResult UpdateCatalogueItem(int catalogueId) { CatalogueItemEF catItem = stockService.FindCatalogueItemById(catalogueId); if (catItem == null) { return(View("Error")); } CatalogueItemDTO item = new CatalogueItemDTO() { CatalogueId = catItem.CatalogueId, ItemCode = catItem.ItemCode, Description = catItem.Stock.Description, ReorderLevel = catItem.ReorderLevel, ReorderQty = catItem.ReorderQty }; return(View(item)); }
public void CreateCatalogueItem(CatalogueItemEF item) { stockEFF.AddToCatalogueItem(item); }
public void RemoveFromCatalogue(CatalogueItemEF item) { context.CatalogueItems.Remove(item); context.SaveChanges(); }
public void AddToCatalogueItem(CatalogueItemEF item) { context.CatalogueItems.Add(item); context.SaveChanges(); }
public ActionResult CreateRequest(RequestListDTO requestListDTO, string items, string decision) { StaffEF staff = staffService.GetStaff(); ViewBag.staff = staff; List <CatalogueItemEF> catalogueList = stockService.ListCatalogueItems(); ViewBag.catalogueList = catalogueList; //validate request details if (requestListDTO.RequestId != null) { ViewBag.amend = true; } if (decision == "Delete") { rndService.DeleteRequest(requestListDTO.RequestId); return(RedirectToAction("Index")); } if (decision == null) { ViewBag.note = "Invalid quantity detected. Please amend."; } if (items != null && decision == "Add Item") { CatalogueItemEF newItem = null; bool checkValid = false; foreach (var item in catalogueList) { if (item.Stock.Description == items) { checkValid = true; newItem = item; break; } } if (!checkValid) { ViewBag.note = "The item is not recognised. Please select another item from the list"; } if (requestListDTO.ItemDescription.Count > 0 && checkValid == true) { foreach (var description in requestListDTO.ItemDescription) { if (description == items) { checkValid = false; ViewBag.note = "The item has already been added to the request list"; break; } } } if (checkValid) { requestListDTO = rndService.AddToRequestListDTO(requestListDTO, newItem.Stock.Description, newItem.Stock.Uom); } } if (decision == "Remove Selected Items") { int before = requestListDTO.ItemDescription.Count; requestListDTO = rndService.RemoveFromRequestListDTO(requestListDTO); int after = requestListDTO.ItemDescription.Count; if (before != after) { ModelState.Clear(); } else { ViewBag.note = "Please check the remove box to remove selected row"; } } if (decision == "Submit" || decision == "Update") { if (requestListDTO.ItemDescription.Count == 0) { ViewBag.note = "You will need to have at least one item in the request"; } else { //save request details when there are no errors rndService.CreateRequest(staff, requestListDTO); return(RedirectToAction("Index")); } } return(View(requestListDTO)); }