internal static GraphqlEntityContext AddSales(this GraphqlEntityContext context) { if (!context.Sale.Any(x => x.Identification == "Initial")) { var user = context.User.Where(x => x.Identification == "InitialUSer").FirstOrDefault(); ; } return context; }
public SaleQuery(GraphqlEntityContext context) { Field <ListGraphType <SaleType> >( "Sale", resolve: a => { var sales = context.Sale.Select(x => new Sale { Id = x.Id, Identification = x.Identification, UserId = x.UserId, User = new User { Id = x.User.Id, Identification = x.User.Identification }, Product = x.Product.Select(y => new Product { Id = y.Id, Identification = y.Identification, UserId = y.UserId, ProductTypeId = y.ProductTypeId, ProductType = new ProductType { Id = y.ProductType.Id, Identification = y.ProductType.Identification }, User = new User { Id = y.User.Id, Identification = y.User.Identification } }).ToList() }); return(sales); }); }
public SalesController(GraphqlEntityContext context) { _context = context; }
internal static GraphqlEntityContext Commit(this GraphqlEntityContext context) { context.SaveChanges(); return context; }
internal static GraphqlEntityContext AddUser(this GraphqlEntityContext context) { if (!context.User.Any(x => x.Identification == "InitialUSer")) { var userInit = new Models.User { Identification = "InitialUSer" }; var userCommum = new Models.User { Identification = "userCommum" }; var userSales = new Models.User { Identification = "userSales" }; context.User.Add(userInit); context.User.Add(userCommum); context.User.Add(userSales); var pc = new Models.ProductType { Identification = "PC2" }; context.ProductType.Add(pc); var placaMae = new Models.Product { Identification = "Placa de video", ProductType = pc, User = userCommum }; context.Product.Add(placaMae); context.Sale.Add(new Models.Sale { Identification = "Initial", Product = new List<Models.Product> { new Models.Product { Identification= "Placa de video", ProductType =pc, User = userCommum }, placaMae }, User = userInit }); context.Sale.Add(new Models.Sale { Identification = "Initial2", Product = new List<Models.Product> { new Models.Product { Identification= "Placa de video2", ProductType = pc, User = userInit }, placaMae }, User = userInit }); } return context; }