Exemplo n.º 1
0
        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)));
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the Multiselect list for the tasks ListBox
        /// </summary>
        /// <param name="selectedValues"></param>
        /// <returns></returns>
        private static MultiSelectList GetTalksList(int[] selectedTasks)
        {
            var talksRepository = new TalksRepository();

            var talks = TalksRepository.GetTalks();

            return(new MultiSelectList(talks, "Id", "Title", selectedTasks));
        }
Exemplo n.º 3
0
        //
        // GET: /Talks/
        public ActionResult Index()
        {
            this.ViewData["talks"] = (from t in TalksRepository.GetTalks()
                                      orderby t.Id descending
                                      select t).ToArray();

            return(this.View());
        }
Exemplo n.º 4
0
        public async void AllocateTalks()
        {
            // arrange
            _talksRepository = new TalksRepository();
            _service         = new TalkAllocationService();
            // act
            var meeting = await _service.CreateMeeting(_talksRepository.TestInput);

            // assert
            Assert.NotNull(meeting);
        }
Exemplo n.º 5
0
        public async void CreateTracks()
        {
            // arrange
            _tracks          = new List <Track>();
            _talksRepository = new TalksRepository();
            _service         = new TalkAllocationService();
            // act
            _tracks = (List <Track>) await _service.CreateTracksFromTalks(_talksRepository.TestInput);

            // assert
            Assert.NotNull(_tracks);
        }
        public async Task <ActionResult <MeetingViewModel> > GetMeetingAsync()
        {
            _talksRepository = new TalksRepository();



            var meeting = await _service.CreateMeeting(_talksRepository.TestInput);

            var meetingViewModel = new MeetingViewModel {
                TestInput = _talksRepository.TestStringInput, TestOutput = meeting
            };

            return(meetingViewModel);
        }
Exemplo n.º 7
0
        private static void createConferenceFromTalks(TalksRepository repository)
        {
            var createFromTalksInterface = new Conferences.CreateFromTalks.ReferenceConsoleInterface(
                new Conferences.CreateFromTalks.ReferenceAdministrator()
                );

            try
            {
                createFromTalksInterface.execute(repository.list(), 180, 240);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 8
0
        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());
            }
        }
Exemplo n.º 9
0
        public ConferenceQuery(SpeakersRepository speakersRepo, TalksRepository talksRepo, FeedbackService feedbackService, IDataLoaderContextAccessor accessor)
        {
            Field <ListGraphType <Types.Speaker> >(
                "speakers",
                Description = "will return all the speakers from current and past editions",
                resolve: context => speakersRepo.GetAll()
                );


            //Field<ListGraphType<Talk>>(
            //    "talks",
            //    Description = "will return all the talks from current and past editions",
            //    resolve: context => talksRepo.GetAll()
            //);



            Field <ListGraphType <Talk>, IEnumerable <Data.Entities.Talk> >()
            .Name("talks")
            .Description("Get all talks in the system")
            .ResolveAsync(ctx =>
            {
                // Get or add a loader with the key "GetAllUsers"
                var loader = accessor.Context.GetOrAddLoader("talksdssd",
                                                             () => talksRepo.GetAllAsync());

                // Prepare the load operation
                // If the result is cached, a completed Task<IEnumerable<User>> will be returned
                return(loader.LoadAsync());
            });



            //  Field<ListGraphType<FeedbackType>>(
            //      "feedbacks",
            //      Description = "will return all the feedbacks",
            //      resolve: context => feedbackService.GetAll()
            //);


            //caches subsequent calls using IDataLoaderContextAccessor
            Field <ListGraphType <FeedbackType>, IEnumerable <Feedback> >()
            .Name("feedbacks")
            .Description("Get all feedbacks")
            .ResolveAsync(ctx =>
            {
                // Get or add a loader with the key "GetAllUsers"
                var loader = accessor.Context.GetOrAddLoader("GetAllFeedbacks",
                                                             () => feedbackService.GetAll());

                // Prepare the load operation
                // If the result is cached, a completed Task<IEnumerable<User>> will be returned
                return(loader.LoadAsync());
            });


            Field <ListGraphType <Types.Talk> >(
                "talksForASpeaker",
                Description = "will return all the talks for a speaker",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(talksRepo.GetAllForSpeaker(id));
            }
                );


            //gets a speaker by id

            Field <Speaker>(
                "speakerById",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name         = "id",
                DefaultValue = 2,
                Description  = "test"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(speakersRepo.GetById(id));
            }
                );

            //gets a talk by id
            Field <Talk>(
                "talk",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(talksRepo.GetById(id));
            }
                );
        }
Exemplo n.º 10
0
        public ActionResult GetTalks()
        {
            var talks = TalksRepository.GetTalks();

            return(Json(talks));
        }
Exemplo n.º 11
0
 // GET: /Talks/Create
 public ActionResult Create()
 {
     this.ViewData["categories"] = TalksRepository.GetCategories();
     return(View());
 }
Exemplo n.º 12
0
 //
 // GET: /Talks/Details/5
 public ActionResult Details(string title)
 {
     return(View(TalksRepository.GetTalkByTitle(title)));
 }