Example #1
0
        //[AbpAuthorize(PermissionNames.Page_Tag_Delete)]
        public async Task <bool> DeleteTagAsync(DeleteTagDto input)
        {
            PermissionChecker.Authorize(PermissionNames.Page_Tag_Delete);

            await _tagRepository.DeleteAsync(input.Id);

            return(true);
        }
Example #2
0
        public async Task <IActionResult> DeleteTag([FromBody] DeleteTagDto deleteTag)
        {
            var result = await _tagService.DeleteTag(deleteTag);

            return(StatusCode(result, new
            {
                Message = "The tag has been deleted"
            }));
        }
Example #3
0
        public async Task <CommandResult> DeleteTag(DeleteTagDto deleteTagDto)
        {
            if (deleteTagDto == null || deleteTagDto.TagId == 0)
            {
                return(new CommandResult(new ErrorMessage
                {
                    ErrorCode = "CATALOG.TAG.DELETE.NULL",
                    Message = "Please send valid data",
                    StatusCode = System.Net.HttpStatusCode.BadRequest
                }));
            }

            var tag = _tagsRepo.Table.SingleOrDefault(t => t.TagId == deleteTagDto.TagId);

            if (tag is null)
            {
                return(new CommandResult(new ErrorMessage
                {
                    ErrorCode = "CATALOG.TAG.DELETE.NOTFOUND",
                    Message = "The tag you are trying to delete does not exists",
                    StatusCode = System.Net.HttpStatusCode.BadRequest
                }));
            }

            try
            {
                tag.TagStatus = TagStatus.Deleted;
                await _tagsRepo.SaveChangesAsync();

                return(new CommandResult());
            }
            catch (Exception e)
            {
                _logger.LogError(e, "There were an error while deleting a tag {tagId}", deleteTagDto.TagId);
                return(new CommandResult(new ErrorMessage
                {
                    ErrorCode = "CATALOG.TAG.DELETE.ERROR",
                    Message = "There were an error while executing your request",
                    StatusCode = System.Net.HttpStatusCode.InternalServerError
                }));
            }
        }
        public JObject DeleteTag(DeleteTagDto dto)
        {
            JObject jo      = new JObject();
            var     isExist = WebapiDbContext.Tags.Where(o => o.Id == dto.Tag_id).FirstOrDefault();

            if (isExist == null)
            {
                jo["stateCode"] = 400;
                jo["message"]   = "标签名不存在,无法删除!";
                return(jo);
            }
            else
            {
                isExist.Is_deleted = "是";
                WebapiDbContext.SaveChanges();
                jo["stateCode"] = 200;
                jo["message"]   = "success!";
                return(jo);
            }
        }
Example #5
0
 public IActionResult DeleteTag([FromServices] IWebapiService webapiService, [FromBody] DeleteTagDto dto)
 {
     return(Json(webapiService.DeleteTag(dto)));
 }