public virtual async Task <DataDto> CreateAsync(DataCreateDto input)
        {
            var data = await DataRepository.FindByNameAsync(input.Name);

            if (data != null)
            {
                throw new UserFriendlyException(L["DuplicateData", input.Name]);
            }

            string code     = string.Empty;
            var    children = await DataRepository.GetChildrenAsync(input.ParentId);

            if (children.Any())
            {
                var lastChildren = children.OrderBy(x => x.Code).FirstOrDefault();
                code = CodeNumberGenerator.CalculateNextCode(lastChildren.Code);
            }
            else
            {
                var parentData = input.ParentId != null
                ? await DataRepository.GetAsync(input.ParentId.Value)
                : null;

                code = CodeNumberGenerator.AppendCode(parentData?.Code, CodeNumberGenerator.CreateCode(1));
            }

            data = new Data(
                GuidGenerator.Create(),
                input.Name,
                code,
                input.DisplayName,
                input.Description,
                input.ParentId,
                CurrentTenant.Id
                );

            data = await DataRepository.InsertAsync(data);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <Data, DataDto>(data));
        }
 public virtual async Task <DataDto> CreateAsync(DataCreateDto input)
 {
     return(await DataAppService.CreateAsync(input));
 }