Skip to content

Library for ASP.Net Web API for partial resource update

License

Notifications You must be signed in to change notification settings

clouty-src/PartialUpdate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PartialUpdate

PartialUpdate is a library for ASP.Net Web API which helps you to implement partial resource update using http request with json body, that contains those fields that need to be updated.

Usage

// Update command definition
public class UserUpdateCommand
{
    [JsonProperty("name")]
    public Assignable<String> Name { get; set; }

    [JsonProperty("about")]
    public Assignable<String> About { get; set; }
}

// Update action
[Route("users/{userID}"), HttpPatch]
public IHttpActionResult UpdateUser(
    Guid userID,
    [PartialUpdate] UserUpdateCommand userUpdateCommand)
{
    var user = UserRepository.GetByID(userID);

    userUpdateCommand.Name.Apply(n => user.Name = n);
    userUpdateCommand.About.Apply(a => user.About = a);

    UserRepository.Save(user);

    return Ok();
}

Nuget

Partial Update Package

Collaboration

If you use this library and know how to make it better - create issue or fork, improve and make pull request!

About

Library for ASP.Net Web API for partial resource update

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages