Esempio n. 1
0
        public async Task <JsonResult> Delete([FromBody] CategoryDeleteDto categoryDeleteDto)
        {
            if (categoryDeleteDto == null)
            {
                return(Json(new JResult
                {
                    Status = Status.BadRequest,
                    Message = "Silinmek istenen kategori bulunamadı!"
                }));
            }

            if (!await _categoryService.CategoryExistsAsync(categoryDeleteDto.Id))
            {
                return(Json(new JResult
                {
                    Status = Status.NotFound,
                    Message = "Silinmek istenen kategori bulunamadı!"
                }));
            }

            var category = await _categoryService.FindByIdAsync(categoryDeleteDto.Id);

            category.IsDelete = false;

            await _categoryService.UpdateAsync(category);


            return(Json(new JResult
            {
                Status = Status.Ok,
                Message = "Kategori başarıyla silindi."
            }));
        }
        public IActionResult Delete([FromBody] CategoryDeleteDto categoryDeleteDto)
        {
            CategoryDeleteCommand categoryDeleteCommand = MapService.Map(categoryDeleteDto);
            Result result = _messages.Dispatch(categoryDeleteCommand);

            return(FromResult(result));
        }
        public async Task <IActionResult> DeleteCategory(Guid id)
        {
            var model = new CategoryDeleteDto()
            {
                Id = id
            };
            await _categoryService.DeleteAsync(model);

            return(NoContent());
        }
        public async Task <ApiResult> DeleteCategory(CategoryDeleteDto input)
        {
            var goodsCategory = await repository.GetAsync(input.Id);

            if (goodsCategory == null)
            {
                throw new ApplicationServiceException("没有找到该商品分类!");
            }
            repository.Delete(goodsCategory);
            if (await new CheckGoodsCategoryCanRemoveSpecification(goodsRepository).IsSatisfiedBy(goodsCategory))
            {
                await unitofWork.CommitAsync();
            }
            return(ApiResult.Ok("商品分类删除成功"));
        }
Esempio n. 5
0
        public async Task DeleteAsync(CategoryDeleteDto dto)
        {
            if (dto.Id == Guid.Empty)
            {
                throw new ArticleException(ArticleErrorCodes.CategoryIdCannotBeNull, "Category Id field is mandatory.", dto);
            }

            var entity = await _categoryRepository.GetByIdAsync(dto.Id);

            if (entity == null)
            {
                throw new ArticleException(ArticleErrorCodes.CategoryCouldNotBeFound, "Category could not be found.", dto);
            }

            await _categoryRepository.DeleteAsync(entity);
        }
Esempio n. 6
0
        public async Task <bool> DeleteAsync(CategoryDeleteDto model)
        {
            using (var tran = databaseFixture.Db.BeginTransaction())
            {
                try
                {
                    var dbmodel = await databaseFixture.Db.WorkflowCategory.GetCategoriesAsync(model.Ids);

                    foreach (var item in dbmodel)
                    {
                        item.Status = 0;
                    }
                    await databaseFixture.Db.WorkflowCategory.BulkUpdateAsync(dbmodel, tran);

                    tran.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    return(false);
                }
            }
        }
Esempio n. 7
0
 public async Task <bool> DeleteAsync([FromBody] CategoryDeleteDto model)
 {
     model.UserId = UserIdentity.UserId.ToString();
     return(await categoryService.DeleteAsync(model));
 }
 public async Task <bool> DeleteAsync([FromBody] CategoryDeleteDto model)
 {
     return(await categoryService.DeleteAsync(model));
 }
Esempio n. 9
0
        public async Task <bool> DeleteAsync(CategoryDeleteDto model)
        {
            var uri = API.Category.DeleteAsync(_baseUrl);

            return(await _apiClient.PostBooleanAsync(uri, model));
        }