-
Notifications
You must be signed in to change notification settings - Fork 0
Home
jayoungers edited this page Oct 12, 2018
·
3 revisions
PatchMap
is a .Net library intended to simplify the process of creating and updating entities in your REST based applications.
After defining a map for an entity (a Blog
, for example), you can Insert, Update, and Patch that entity using the same code:
[RoutePrefix("api/blogs")]
public class BlogsController : BaseController
{
public BlogsController(ExampleContext dbContext) : base(dbContext) { }
[HttpPost, Route("")]
public PatchCommandResult<BlogViewModel> Insert(BlogViewModel blog)
{
return new BlogPatchCommand(DbContext).Execute(null, blog.ToPatchOperations());
}
[HttpPut, Route("{id}")]
public PatchCommandResult<BlogViewModel> Update(int id, BlogViewModel blog)
{
return new BlogPatchCommand(DbContext).Execute(id, blog.ToPatchOperations());
}
[HttpPatch, Route("{id}")]
public PatchCommandResult<BlogViewModel> Patch(int id, List<JsonPatch> patches)
{
return new BlogPatchCommand(DbContext).Execute(id, patches.ToPatchOperations<BlogViewModel>());
}
}
Concepts
PatchMap Library
Examples