public async Task <AddProductPayload> AddProductAsync( AddProductInput input, [ScopedService] NakodaAgenciesDbContext context, [Service] ITopicEventSender eventSender, CancellationToken cancellationToken ) { try { //List<TestGraphQL.Models.Product> _address = Builder<TestGraphQL.Models.Product>.CreateListOfSize(10000).All() // .With(c => c.ProductName = Faker.Address.StreetName()) // ).Build().ToList(); var region = new TestGraphQL.Models.Product { ProductName = input.ProductName, Active = true, CreatedDate = DateTime.Now }; context.Products.AddRange(region); await context.SaveChangesAsync(cancellationToken); await eventSender.SendAsync(nameof(ProductSubscription.OnProductAdded), region, cancellationToken); var _regionResponse = (from _region in context.Products where _region.ProductId.Equals(region.ProductId) select new Models.Product { ProductId = _region.ProductId ?? default(Guid), ProductName = _region.ProductName, Active = _region.Active, CreatedDate = _region.CreatedDate }).FirstOrDefault(); return(new AddProductPayload(_regionResponse)); } catch (Exception ex) { throw; } }
public AddProductPayload(TestGraphQL.Models.Product product) { Product = product; }