//POST: EDIT PRODUCT //ONLY VENDOR AND ADMIN IS AUTHORISED public ActionResult EditProduct(int id) { ProductModel product = null; try { product = productActionContext.GetProductById(id); } catch (Exception e) { //LOG EXCEPTION logger.Error("Product not loaded by EditProduct() of Product Controller : ", e); } if (product == null) { return(HttpNotFound()); } IEnumerable <CategoryModel> categoryList = productActionContext.GetCategories(); ViewBag.Category = categoryList; return(View(product)); }
public void GetByID_ReturnsCorrectNumber() { //Arrange var expectedService = new Product() { ID = 1, Name = "First" }; _productRepository.Setup(x => x.GetOne(It.IsAny <Func <Product, bool> >())) .Returns(expectedService); //Act var result = _service.GetProductById(1); //Assert Assert.IsNotNull(result); Assert.AreEqual(expectedService.ID, result.ID); Assert.AreEqual(expectedService.Name, result.Name); }
// GET: api/Product/5 public MProduct Get(int id) { ProductActions p1 = new ProductActions(); return(p1.GetProductById(id)); }