Beispiel #1
0
        public async Task <IActionResult> DeleteAsync([FromRoute] string tagId)
        {
            if (!Guid.TryParse(tagId, out var id))
            {
                return(BadRequest(new ErrorResponse {
                    Error = "Invalid tag id"
                }));
            }

            var userId = _identityService.GetUserIdentity();
            var tag    = await _tagsService.GetByIdAsync(id, userId).ConfigureAwait(false);

            if (tag == null)
            {
                return(NotFound());
            }

            var exist = await _tagsService.CheckLinkedLocksExistence(id, userId).ConfigureAwait(false);

            if (exist)
            {
                return(BadRequest(new ErrorResponse {
                    Error = "Could not delete tag wih linked locks"
                }));
            }

            var deleted = await _tagsService.DeleteAsync(id, userId).ConfigureAwait(false);

            if (!deleted)
            {
                return(NotFound());
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            var result = await _tagsService.DeleteAsync(id);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var tagsResource = _mapper.Map <Tags, TagsResource>(result.Resource);

            return(Ok(tagsResource));
        }
        public IHttpActionResult DeleteAsync(int id)
        {
            _tagsService.DeleteAsync(id);

            return(Ok());
        }