Example #1
0
        public async Task <IActionResult> CreateTag([FromBody] DtoNewTag newTag)
        {
            var tag = new Tag
            {
                TagName = newTag.TagName
            };

            return(await tags.CreateTag(tag)
                   .Ensure(t => t.HasValue, "Tag successfully created")
                   .OnSuccess(t => new Tag {
                TagId = t.Value, TagName = tag.TagName
            })
                   .OnBoth(t => t.IsFailure ? StatusCode(404, "") : StatusCode(200, t.Value))
                   .ConfigureAwait(false));
        }
Example #2
0
        public async Task <IActionResult> ReplaceTag([FromRoute(Name = "tagId")] int tagId, [FromBody] DtoNewTag newTag)
        {
            var tag = new Tag
            {
                TagId   = tagId,
                TagName = newTag.TagName
            };

            return(await tags.ReplaceTag(tag)
                   .OnBoth(t => t.IsFailure ? StatusCode(404) : StatusCode(200))
                   .ConfigureAwait(false));
        }