public async Task CreateOrUpdateStoreContainer(CreateOrUpdateStoreContainerInput input)
 {
     if (input.StoreContainer.Id.HasValue)
     {
         await UpdateStoreContainer(input);
     }
     else
     {
         await CreateStoreContainer(input);
     }
 }
        private async Task UpdateStoreContainer(CreateOrUpdateStoreContainerInput input)
        {
            var storeContainer =
                await _storeContainerRepository.FirstOrDefaultAsync(p => p.Id == input.StoreContainer.Id);

            if (storeContainer != null)
            {
                storeContainer.Name             = input.StoreContainer.Name;
                storeContainer.AdministratorIds = input.StoreContainer.AdministratorIds;
                storeContainer.Describe         = storeContainer.Describe;
            }
            else
            {
                throw new UserFriendlyException($"更新失败!未能找到Id为{input.StoreContainer.Id}的库存容器对象");
            }
        }
        private async Task CreateStoreContainer(CreateOrUpdateStoreContainerInput input)
        {
            var storeContainer = new StoreContainer(input.StoreContainer.Name)
            {
                AdministratorIds = input.StoreContainer.AdministratorIds,
                Describe         = input.StoreContainer.Describe
            };

            if (input.FatherContainerId.HasValue)
            {
                var fatherStore =
                    await _storeContainerRepository.GetAllIncluding(p => p.StoreContainers).FirstOrDefaultAsync(p => p.Id == input.FatherContainerId);

                if (fatherStore != null)
                {
                    if (fatherStore.FileStoreInfos != null)
                    {
                        fatherStore.StoreContainers.Add(storeContainer);
                    }
                    else
                    {
                        fatherStore.StoreContainers = new List <StoreContainer> {
                            storeContainer
                        };
                    }
                }
                else
                {
                    throw new UserFriendlyException($"创建失败!未找到Id为{input.FatherContainerId.ToString()}的父容器");
                }
            }
            else
            {
                await _storeContainerRepository.InsertAsync(storeContainer);
            }
        }