public async Task TestUpdate() { var products1 = await _pManager.GetAllProducts(); products1[0].Price = 12.00M; var p = await _pManager.UpdateProduct(products1[0].ProductId, products1[0]); Assert.AreEqual <decimal>(p.Price, 12.00M); }
public async Task <IHttpActionResult> PutProduct([FromUri] Guid id, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductId) { return(BadRequest()); } //db.Entry(product).State = EntityState.Modified; try { // await db.SaveChangesAsync(); await _productManager.UpdateProduct(id, product); } catch (SqlException e) { return(BadRequest(e.GetBaseException().Message)); } catch (CustomException.NotFoundException <Product> e) { return(NotFound()); } catch (Exception e) { throw new CustomException.GeneralErrorMessage(e.GetBaseException().Message); } return(StatusCode(HttpStatusCode.NoContent)); }