public object Post(BlogItemInput input) { int? imageId = null; MemoryStream imageData = new MemoryStream(); if (input.Image != null && input.Image.Length > 0) { CopyStream(input.Image.OpenStream(), imageData); ImageDB.ImageEntry imageEntry = ImageDB.AddImage(input.Image.FileName, input.Image.ContentType, imageData); imageId = imageEntry.Id; } BlogDB.PostEntry postEntry = BlogDB.AddPost(input.Title, input.Text, 1, imageId); BlogItemHandler h = new BlogItemHandler(); BlogItem createdItem = h.Get(postEntry.Id); return(new OperationResult.Created { ResponseResource = createdItem, RedirectLocation = typeof(BlogItem).CreateUri(new { id = postEntry.Id }) }); }