private void Enrich(TodoRepresentation todo, UrlHelper url)
 {
     var selfUrl = url.Link("DefaultApi", new { controller = "todos", todo.id });
     todo.AddLink(new SelfLink(selfUrl));
     todo.AddLink(new EditLink(selfUrl));
     todo.AddLink(new DeleteLink(selfUrl));
 }
Ejemplo n.º 2
0
        public async Task <NoContentResult> Update(string id, [FromBody] TodoRepresentation item)
        {
            await _todoStore.Update(id,
                                    todo =>
            {
                todo.Name = item.Name
                            .ThrowInvalidDataExceptionIfNullOrWhiteSpace("A todo must have a name");

                todo.State = item.State;
                todo.Due   = item.Due;
            });

            return(NoContent());
        }
 /// <summary>
 /// Used to determine if the model and representations are equivalent
 /// </summary>
 /// <param name="model"></param>
 /// <param name="representation"></param>
 /// <returns></returns>
 private static bool AreEquivalent(TodoModel model, TodoRepresentation representation)
 {
     return
         model.id == representation.id &&
         model.completed == representation.completed &&
         model.deadlineUtc == representation.deadlineUtc &&
         model.moreDetails == representation.moreDetails &&
         model.task == representation.task;
 }