private async ValueTask <(Product product, string error)> CreateProduct(ProductDTO entityDTO, ICollection <Photo> defaultPhotoList = null, List <Photo> scheduleAddedPhotoList = null, List <Photo> scheduleDeletePhotoList = null) { var product = new Product() { CategoryId = entityDTO.NewCategoryId, SubcategoryId = entityDTO.NewSubcategoryId, ProductId = entityDTO.Alias.TransformToId(), Alias = entityDTO.Alias, Price = entityDTO.Price, Description = entityDTO.Description, IsVisible = entityDTO.IsVisible ?? true, SeoTitle = entityDTO.SeoTitle, SeoDescription = entityDTO.SeoDescription, SeoKeywords = entityDTO.SeoKeywords, Photos = new List <Photo>() }; //Добавляем и проверяем можем ли мы добавить данную категорию var(isSuccess, error) = await _repository.AddProduct(product); if (!isSuccess) { return(null, error); } _photoEntityUpdater.MovePhotosToEntity(product, defaultPhotoList); await _photoEntityUpdater.LoadPhotosToEntity(product, entityDTO, scheduleAddedPhotoList, scheduleDeletePhotoList); await _context.SaveChangesAsync(); return(product, null); }