public void SaveProductTest() { // Arrange - create a repository EFProductRepository target = new EFProductRepository(); // Act - change the category of the first product Product prod = target.Products.First(); prod.Category = "Test"; target.SaveProduct(prod); }
// GET api/<controller>/5 public HttpResponseMessage Get(int id) { EFProductRepository repo = new EFProductRepository(); var prod = repo.Products.SingleOrDefault(p => p.ProductID == id); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); Stream strm = new MemoryStream(prod.ImageData); response.Content = new StreamContent(strm); response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentDisposition.FileName = "hyundai.apk"; repo = null; return response; }