/// <summary> /// Reverse map with validation across-the-wire representation into in-memory representation /// </summary> public static TagCreateData FromRepresentation(this TagCreateDataRepresentation todo) { return(new TagCreateData { Name = todo.Name .ThrowInvalidDataExceptionIfNullOrWhiteSpace("A tag requires a name"), }); }
public async Task <CreatedResult> CreateTag([FromBody] TagCreateDataRepresentation tag, string id) { var tagId = await _tagStore.Create( User.GetId(), TrustDefaults.KnownHomeResourceId, tag.ThrowInvalidDataExceptionIfNull("Invalid tag create data").FromRepresentation(), Permission.Get, CallerCollectionRights.Tag); await _todoStore.AddTag(id, tagId); return(tagId .MakeTodoTagUri(id, Url) .MakeCreated()); }