< Summary

Class:SVETA.Api.Services.Implements.CategoryWorker
Assembly:SVETA.Api
File(s):/opt/dev/sveta_api_build/SVETA.Api/Services/Implements/CategoryWorker.cs
Covered lines:0
Uncovered lines:14
Coverable lines:14
Total lines:43
Line coverage:0% (0 of 14)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodLine coverage Branch coverage
.ctor(...)0%100%
Delete()0%0%

File(s)

/opt/dev/sveta_api_build/SVETA.Api/Services/Implements/CategoryWorker.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Threading.Tasks;
 5using SVETA.Api.Data.DTO.Showcase;
 6using SVETA.Api.Services.Interfaces;
 7using WinSolutions.Sveta.Server.Services.Interfaces;
 8using Microsoft.Extensions.Logging;
 9using AutoMapper;
 10using WinSolutions.Sveta.Server.Data.DataModel.Entities;
 11using WinSolutions.Sveta.Server.Data.DataModel.Kinds;
 12using SVETA.Api.Data.DTO;
 13using WinSolutions.Sveta.Server.Data.DataModel.Extensions;
 14
 15namespace SVETA.Api.Services.Implements
 16{
 17    public class CategoryWorker : ICategoryWorker
 18    {
 19        private readonly ICategoryService _categoryService;
 20        private readonly IGoodService _goodService;
 21
 022        public CategoryWorker(ICategoryService categoryService, IGoodService goodService)
 023        {
 024            _categoryService = categoryService;
 025            _goodService = goodService;
 026        }
 27
 28        public async Task Delete(long id)
 029        {
 030            if((await _categoryService.GetChildCategoriesCount(id)) > 0)
 031            {
 032                throw new ArgumentException("Невозможно удалить категорию с подкатегориями");
 33            }
 34
 035            if((await _goodService.GetGoodsCount(null, id, false)) > 0)
 036            {
 037                throw new ArgumentException("Невозможно удалить категорию с товарами");
 38            }
 39
 040            await _categoryService.DeleteCategory(id);
 041        }
 42    }
 43}

Methods/Properties

.ctor(...)
Delete()