public async Task TestDelete() { var products1 = await _pManager.GetAllProducts(); var product = await _pManager.DeleteProduct(products1[0].ProductId); Assert.IsNotNull(product); }
public async Task <IHttpActionResult> DeleteProduct([FromUri] Guid id) { Product product; //if (product == null) //{ // return NotFound(); //} // db.Products.Remove(product); // await db.SaveChangesAsync(); try { product = await _productManager.DeleteProduct(id); } 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(Ok(product)); }