public IHttpActionResult PutPicture(int id, Picture picture) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != picture.PictureId) { return(BadRequest()); } db.Entry(picture).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PictureExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void Main(string[] args) { Console.Write("Program start!"); using (var db = new ImageLibraryContext()) { db.Pictures.Add(new Picture() { PictureTitle = "VegardsBilde", UploadDate = DateTime.Now, LocalFilePath = "F://Vetle.jpg" }); db.SaveChanges(); } Console.Write("Program done..."); Console.Read(); }