public ActionResult DeleteConfirmed(int id) { DimProduct dimproduct = db.DimProduct.Find(id); db.DimProduct.Remove(dimproduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Fill(DimProduct dimProduct) { Color = dimProduct.Color; DealerPrice = dimProduct.DealerPrice; ProductKey = dimProduct.ProductKey; ProductName = dimProduct.EnglishProductName; ProductSubcategoryKey = dimProduct.ProductSubcategoryKey; ReorderPoint = dimProduct.ReorderPoint; SafetyStockLevel = dimProduct.SafetyStockLevel; }
public ActionResult Edit(DimProduct dimproduct) { if (ModelState.IsValid) { db.Entry(dimproduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dimproduct)); }
public ActionResult Create(DimProduct dimproduct) // Need to add AntiForgeryToken for { // Create and Edit posts if (ModelState.IsValid) { db.DimProduct.Add(dimproduct); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dimproduct)); }
// POST: odata/Products public IHttpActionResult Post(DimProduct dimProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DimProducts.Add(dimProduct); db.SaveChanges(); return(Created(dimProduct)); }
public bool UpdateProduct(Product product) { var dimProduct = new DimProduct() { ProductKey = product.ProductKey, EnglishProductName = product.Name, SafetyStockLevel = product.StockLevel }; var result = oAService.UpdateProduct(dimProduct); return(result > 0); // TODO: Update Product (Name and StockLevel properties only) and map To DimProduct (OAServer class) (see mapping above) }
// DELETE: odata/Products(5) public IHttpActionResult Delete([FromODataUri] int key) { DimProduct dimProduct = db.DimProducts.Find(key); if (dimProduct == null) { return(NotFound()); } db.DimProducts.Remove(dimProduct); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public bool UpdateProduct(Models.Product product) { if (product == null) { throw new ArgumentNullException("product"); } var dimProduct = new DimProduct { EnglishProductName = product.Name, ProductKey = product.ProductKey, SafetyStockLevel = product.StockLevel }; var productId = _oaService.UpdateProduct(dimProduct); return(productId > 0); }
public static IProduct GetProduct(DimProduct dimProduct) { IProduct product; switch (dimProduct.ProductKey) { case 0: product = new DefaultProduct(); break; default: product = new Product(); break; } product.Fill(dimProduct); return(product); }
public void ReadDimProduct_Succeed() { var dimProducts = _rootContext.DimProducts.Take(10).ToList(); var dimProductEntry = _rootContext.Entry(dimProducts.First()); var dimProductNew = new DimProduct() { }; var dimProductNewEntry = _rootContext.Entry(dimProductNew); _rootContext.DimProducts.Attach(dimProductNew); dimProductNewEntry = _rootContext.Entry(dimProductNew); var dimProductNewFromContext = _rootContext.DimProducts.Create(); var dimProductNewFromContextEntry = _rootContext.Entry(dimProductNewFromContext); Assert.That(dimProducts.Any()); Assert.That(dimProductEntry.State == System.Data.Entity.EntityState.Unchanged); }
public void SetUp() { _mockIOAService = new Mock <IOAServiceAgent>(); _productRepository = new ProductRepository(_mockIOAService.Object); _mockDimProducts[0] = new DimProduct() { EnglishProductName = "Fruit", ProductKey = 1, SafetyStockLevel = 123 }; _mockDimProducts[1] = new DimProduct() { EnglishProductName = "Bread", ProductKey = 2, SafetyStockLevel = 456 }; _mockDimProducts[2] = new DimProduct() { EnglishProductName = "Coca", ProductKey = 3, SafetyStockLevel = 789 }; }
// PUT: odata/Products(5) public IHttpActionResult Put([FromODataUri] int key, Delta <DimProduct> patch) { Validate(patch.GetInstance()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DimProduct dimProduct = db.DimProducts.Find(key); if (dimProduct == null) { return(NotFound()); } patch.Put(dimProduct); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DimProductExists(key)) { return(NotFound()); } else { throw; } } return(Updated(dimProduct)); }
// // GET: /AWProducts/Edit/5 public ActionResult Edit(int id) { DimProduct dimproduct = db.DimProduct.Find(id); return(View(dimproduct)); }
// // GET: /AWProducts/Details/5 public ViewResult Details(int id) { DimProduct dimproduct = db.DimProduct.Find(id); return(View(dimproduct)); }
public int UpdateProduct(DimProduct product) { return(_oAService.UpdateProduct(product)); }