Skip to content

mrstebo/Nancy.Patch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status

MyGet Prerelease NuGet Version

Nancy.Patch

Add support for patching models

Example

Here is a basic example of how you can use Nancy.Patch in your projects

private dynamic PatchEntry(dynamic parameters)
{
    var customerId = (long) parameters.id;
    var customer = _repo.FindById(customerId);

    // Ensures only properties sent to the request are updated on the customer
    // e.g. { "name": "My New Name" }
    // will only update customer.Name and leave all other properties untouched
    if (!this.Patch(customer))
        return HttpStatusCode.UnprocessableEntity;

    _repo.Save(customer);

    return HttpStatusCode.NoContent;
}