public MusicStoreMutation(IVenueRepository venueRepository, IMusicianRepository musicianRepository) { Field <VenueType>( "createVenue", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <VenueInputType> > { Name = "venue" } ), resolve: context => { var venue = context.GetArgument <Venue>("venue"); return(venueRepository.AddAsync(venue).Result); }); Field <MusicianType>( "createMusician", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <MusicianInputType> > { Name = "musician" } ), resolve: context => { var musician = context.GetArgument <Musician>("musician"); return(musicianRepository.AddAsync(musician).Result); }); }
public async Task <IActionResult> Create([Bind("VenueId,VenueName")] Venue venue) { if (venueRepository.DoesVenueExist(venue.VenueName)) { ModelState.AddModelError("VenueName", "Venue already exists. Please enter another venue."); } else if (ModelState.IsValid) { venue = await venueRepository.AddAsync(venue); await auditLogger.log(GetUserId(), $"Venue Created {venue.VenueName}"); return(RedirectToAction(nameof(Index))); } return(View(venue)); }