Exemplo n.º 1
0
        public async Task <ActionResult> DeleteByTagId(int tagId)
        {
            IEnumerable <MovieTagsDomainModel> deletedMovieTag;

            try
            {
                deletedMovieTag = await _movieTagService.DeleteByTagId(tagId);
            }
            catch (DbUpdateException e)
            {
                ErrorResponseModel errorResponse = new ErrorResponseModel
                {
                    ErrorMessage = e.InnerException.Message ?? e.Message,
                    StatusCode   = System.Net.HttpStatusCode.BadRequest
                };

                return(BadRequest(errorResponse));
            }
            if (deletedMovieTag == null)
            {
                ErrorResponseModel errorResponse = new ErrorResponseModel
                {
                    ErrorMessage = Messages.MOVIETAG_DOES_NOT_EXIST,
                    StatusCode   = System.Net.HttpStatusCode.InternalServerError
                };

                return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, errorResponse));
            }

            return(Accepted(deletedMovieTag.ToList()));
        }
Exemplo n.º 2
0
        public async Task <TagsDomainModel> DeleteTag(int tagId)
        {
            var movieTagData = await _movieTagService.DeleteByTagId(tagId);

            var data = _tagsRepository.Delete(tagId);

            if (data == null)
            {
                return(null);
            }

            _tagsRepository.Save();

            TagsDomainModel domainModel = new TagsDomainModel
            {
                Id   = data.Id,
                Name = data.Name
            };

            return(domainModel);
        }