Beispiel #1
0
        public void PostTag([FromBody] TagCreatingModel tagModel)
        {
            var tagLabel = tagModel.Label;

            if (_service.GetById(tagLabel) == null)
            {
                _service.Create(tagModel);
            }
            else
            {
                _service.Create(tagModel);
            }
        }
        public async Task <IActionResult> Post([FromBody] NewTagDto newTag)
        {
            var createdTag = await _tagsService.Create(newTag);

            var tagUri = CreateResourceUri(createdTag.Id);

            return(Created(tagUri, createdTag));
        }
        public async Task <IActionResult> CreateTag(string name, string description, List <IFormFile> images)
        {
            // If the user sends `images` POST param then the list<IFormFile> will be populated, if the user sends `images[]` instead, then it will be empty
            // this is why I populate that list with this little trick
            if (images?.Count == 0)
            {
                images = Request.Form.Files.GetFiles("images[]").ToList();
            }
            Tag tag = await _tagsService.Create(name, description, images);

            return(StatusCodeAndDtoWrapper.BuildSuccess(TagDto.Build(tag), "Tag created successfully"));
        }
Beispiel #4
0
        public async Task <IActionResult> Post([FromBody] NewTagDto newTagDto)
        {
            try
            {
                var tagId = await _tagsService.Create(newTagDto);

                return(Ok(tagId));
            }
            catch (ValidationException exception)
            {
                return(BadRequest(exception.Message));
            }
            catch (ArgumentNullException exception)
            {
                return(NotFound(exception.Message));
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Create(string text)
        {
            string email = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            if (email != "*****@*****.**")
            {
                return(Unauthorized());
            }

            var createResult = await _tagsService.Create(text);

            if (!createResult.Success)
            {
                return(BadRequest(createResult.Errors));
            }

            return(Ok(new SuccessResponse()));
        }
 public async Task <OperationResult> Create([FromBody] CommonTagModel tag)
 {
     return(await _tagsService.Create(tag.Name));
 }