public static BusinessUnitCategoryDTO ToDTO(this BusinessUnitCategory entity)
        {
            if (entity is null)
            {
                return(null);
            }

            return(new BusinessUnitCategoryDTO()
            {
                Id = entity.Id,
                Name = entity.Name
            });
        }
        public async Task <BusinessUnitCategoryDTO> CreateBusinessUnitCategoryAsync(string businessUnitCategoryName)
        {
            businessValidator.IsNameInRange(businessUnitCategoryName);

            var checkBusinessUnitCategoryNameIfExists = await this.context.BusinessUnitCategories
                                                        .FirstOrDefaultAsync(n => n.Name == businessUnitCategoryName);

            if (checkBusinessUnitCategoryNameIfExists != null)
            {
                throw new AlreadyExistsException(ServicesConstants.BusinessUnitCategoryNameAlreadyExists);
            }

            var businessUnitCategory = new BusinessUnitCategory()
            {
                Name = businessUnitCategoryName
            };

            await this.context.SaveChangesAsync();

            return(businessUnitCategory.ToDTO());
        }