public ConferenceMutation(TalksRepository talkRepository, SpeakersRepository speakersRepository) { FieldAsync <Talk>( "createTalk", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <TalkInput> > { Name = "talkInput" } ), resolve: async context => { var talk = context.GetArgument <Data.Entities.Talk>("talkInput"); //you can also validate return(await context.TryAsyncResolve(async c => await talkRepository.Add(talk))); }); FieldAsync <Speaker>( "createSpeaker", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <SpeakerInput> > { Name = "speakerInput" } ), resolve: async context => { var speaker = context.GetArgument <Data.Entities.Speaker>("speakerInput"); //you can also validate return(await context.TryAsyncResolve(async c => await speakersRepository.Add(speaker))); }); }
public ActionResult Create(string title, string speaker, int categoryId, string description) { try { var talk = new Talk { Description = description, Speaker = speaker, Title = title, Category = TalksRepository.GetCategoryById(categoryId), }; TalksRepository.Add(talk); return(RedirectToAction("Index")); } catch { return(View()); } }