Ejemplo n.º 1
0
        public SpeakersPage()
        {
            InitializeComponent();

            speakersViewModel = new SpeakersViewModel();
            BindingContext    = speakersViewModel;
        }
 /// <summary>
 /// Provides a deterministic way to create the Speakers property.
 /// </summary>
 public static void CreateSpeakers()
 {
     if (_speakers == null)
     {
         _speakers = new SpeakersViewModel();
     }
 }
Ejemplo n.º 3
0
 public SpeakersPage()
 {
     InitializeComponent();
     vm             = new SpeakersViewModel();
     BindingContext = vm;
     ListViewSpeakers.ItemSelected += ListViewSpeakers_ItemSelected;
 }
Ejemplo n.º 4
0
        public SpeakerPage()
        {
            InitializeComponent();
            viewModel      = App.SimpleIoC.Resolve <SpeakersViewModel> ();
            BindingContext = viewModel;

            if (viewModel.CurrentSpeaker.HeadshotUrl.Length > 0)
            {
                try
                {
                    var photo = new CircleImage
                    {
                        BorderColor       = Color.White,
                        BorderThickness   = 3,
                        HeightRequest     = 75,
                        WidthRequest      = 75,
                        Aspect            = Aspect.AspectFill,
                        HorizontalOptions = LayoutOptions.Center,
                        Source            = UriImageSource.FromUri(new Uri(viewModel.CurrentSpeaker.HeadshotUrl))
                                            //Source = UriImageSource.FromFile("TeamMirMaheed")
                                            //Source = UriImageSource.FromUri (new Uri ("http://upload.wikimedia.org/wikipedia/commons/5/55/Tamarin_portrait.JPG"))
                    };
                    stackCircles.Children.Clear();
                    stackCircles.Children.Add(photo);
                }
                catch (Exception exc)
                {
                }
            }
        }
Ejemplo n.º 5
0
        public SpeakersPage()
        {
            InitializeComponent();

            //Create the view model and set as binding context
            vm             = new SpeakersViewModel();
            BindingContext = vm;
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            var vm = new SpeakersViewModel {
                Speakers = DataStore.Speakers.ToList()
            };

            return(View(vm));
        }
Ejemplo n.º 7
0
        // GET: Speakers/Details/5
        public ActionResult Details(int id)
        {
            var speakerDetails      = speakerService.GetById(id);
            SpeakersViewModel model = new SpeakersViewModel();

            model.InjectFrom(speakerDetails);
            return(View(model));
        }
Ejemplo n.º 8
0
        // GET: Speakers/Edit/5
        public ActionResult Edit(int id)
        {
            var speaker             = speakerService.GetSpeakerById(id);
            SpeakersViewModel model = new SpeakersViewModel();

            model.InjectFrom(speaker);
            return(View(model));
        }
Ejemplo n.º 9
0
        public SpeakersPage()
        {
            InitializeComponent();

            //Create the view model and set as binding context
            vm             = new SpeakersViewModel();
            BindingContext = vm;
            ListViewSpeakers.ItemSelected += ListViewSpeakers_ItemSelected;
        }
Ejemplo n.º 10
0
        public ActionResult Edit(int id, SpeakersViewModel model)
        {
            Speakers speakers = new Speakers();

            speakers.InjectFrom(model);
            var speakerToUpdate = speakerService.UpdateSpeaker(speakers);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 11
0
        public ActionResult Delete(int id, SpeakersViewModel model)
        {
            Speakers speakerToDelete = new Speakers();

            speakerToDelete = speakerService.GetSpeakerById(id);
            model.InjectFrom(speakerToDelete);
            speakerService.Delete(speakerToDelete);
            speakerService.Save();
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 12
0
        public DetailsPage(Speaker item, SpeakersViewModel viewModel)
        {
            InitializeComponent();

            this.speaker           = item;
            this.vm                = viewModel;
            BindingContext         = this.speaker;
            ButtonSpeak.Clicked   += ButtonSpeak_Clicked;
            ButtonWebsite.Clicked += ButtonWebsite_Clicked;
            ButtonSave.Clicked    += ButtonSave_Clicked;
        }
Ejemplo n.º 13
0
 public JsonResult Delete(SpeakersViewModel speakersModel)
 {
     try
     {
         _genericService.Delete(speakersModel.ID);
         return(Json(new { Result = "OK" }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "ERROR", Message = ex.Message }));
     }
 }
Ejemplo n.º 14
0
 public JsonResult Edit(SpeakersViewModel speakersModel)
 {
     try
     {
         _genericService.Update(_mapper.Map <SpeakersViewModel, SpeakersDTO>(speakersModel));
         return(Json(new { Result = "OK", Record = speakersModel }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "ERROR", Message = ex.Message }));
     }
 }
Ejemplo n.º 15
0
        public ActionResult Delete(int id, SpeakersViewModel model)
        {
            Speakers deleteSpeaker = new Speakers();

            deleteSpeaker = speakerService.GetById(id);

            model.InjectFrom(deleteSpeaker);

            speakerService.DeleteSpeaker(deleteSpeaker);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Index()
        {
            IEnumerable <SpeakerResponseDto> speakers = await _apiClient.GetSpeakersAsync();

            speakers = speakers.OrderBy(s => s.Name);

            var model = new SpeakersViewModel
            {
                Speakers = speakers
            };

            return(View(model));
        }
Ejemplo n.º 17
0
        public DetailsPage(Speaker item, SpeakersViewModel viewModel)
        {
            InitializeComponent();

            //Set local instance of speaker and set BindingContext
            this.speaker           = item;
            this.vm                = viewModel;
            BindingContext         = speaker;
            ButtonSpeak.Clicked   += ButtonSpeak_Clicked;
            ButtonWebsite.Clicked += ButtonWebsite_Clicked;
            ButtonAnalyze.Clicked += ButtonAnalyze_Clicked;
            ButtonSave.Clicked    += ButtonSave_Clicked;
        }
Ejemplo n.º 18
0
 public JsonResult Create(SpeakersViewModel speakersModel)
 {
     try
     {
         var id = _genericService.Save(_mapper.Map <SpeakersViewModel, SpeakersDTO>(speakersModel));
         speakersModel.ID = id;
         return(Json(new { Result = "OK", Record = speakersModel }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "ERROR", Message = ex.Message }));
     }
 }
Ejemplo n.º 19
0
        public async void Init_ExceptionThrown_ReportsError()
        {
            DataClient.GetDataBody = delegate { throw new Exception(); };
            string errorMessage = null;

            Messenger.Subscribe <ErrorMessage>(msg => errorMessage = msg.Message);

            var viewModel = new SpeakersViewModel(Messenger, CodeCampService);
            await viewModel.Init();

            Assert.NotNull(errorMessage);
            Assert.False(viewModel.IsLoading);
            Assert.Null(viewModel.Speakers);
        }
Ejemplo n.º 20
0
        private void reinitializeChildViewModels()
        {
            OverviewViewModel = new OverviewViewModel(Messenger, _campService);
            OverviewViewModel.Init();

            SessionsViewModel = new SessionsViewModel(Messenger, _campService);
            SessionsViewModel.Init();

            SpeakersViewModel = new SpeakersViewModel(Messenger, _campService);
            SpeakersViewModel.Init();

            SponsorsViewModel = new SponsorsViewModel(Messenger, _campService);
            SponsorsViewModel.Init();
        }
Ejemplo n.º 21
0
        public ActionResult Edit(int id, SpeakersViewModel model)
        {
            if (ModelState.IsValid)
            {
                Speakers speakersToUpdate = new Speakers();
                speakersToUpdate.InjectFrom(model);
                speakerService.Update(speakersToUpdate);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 22
0
        public ActionResult Create(SpeakersViewModel speakers)
        {
            if (ModelState.IsValid)
            {
                Speakers speakerToAdd = new Speakers();
                speakerToAdd.InjectFrom(speakers);
                speakerService.Create(speakerToAdd);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(speakers));
            }
        }
Ejemplo n.º 23
0
        public async void Init_DataLoadsSuccessfully_LoadsSpeakerList()
        {
            var data = new CampData {
                Speakers = new List <Speaker>()
            };

            DataClient.GetDataBody = () => Task.FromResult(data);
            var viewModel = new SpeakersViewModel(Messenger, CodeCampService);

            Assert.True(viewModel.IsLoading);

            await viewModel.Init();

            Assert.AreEqual(data.Speakers, viewModel.Speakers);
            Assert.False(viewModel.IsLoading);
        }
Ejemplo n.º 24
0
        public void ViewSpeakerCommand_NavigatesToSpeaker()
        {
            var speaker = new Speaker {
                Id = 42
            };
            var viewModel = new SpeakersViewModel(Messenger, CodeCampService);

            viewModel.ViewSpeakerCommand.Execute(speaker);

            Assert.AreEqual(1, Dispatcher.ShowViewModelRequests.Count);

            var request       = Dispatcher.ShowViewModelRequests.Single();
            var navParameters = request.ParameterValues.Read(typeof(SpeakerViewModel.NavigationParameters)) as SpeakerViewModel.NavigationParameters;

            Assert.NotNull(navParameters);
            Assert.AreEqual(speaker.Id, navParameters.Id);
        }
        public ActionResult Create(SpeakersViewModel model)
        {
            if (ModelState.IsValid)
            {
                Speakers speaker = new Speakers();
                speaker.InjectFrom(model);
                var speakerToCreate = speakerService.AddSpeaker(speaker);


                if (speakerToCreate == null)
                {
                    ModelState.AddModelError("Name", "Speaker name must be unique!");
                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 26
0
        private void SpeakerListSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                Speaker speaker = e.AddedItems[0] as Speaker;

                if (speaker != null)
                {
                    SpeakersViewModel vm = this.DataContext as SpeakersViewModel;
                    vm.SendSpeakerNavigatingMessage(speaker);
                    ListBox listbox = sender as ListBox;
                    listbox.SelectedIndex = -1;
                }

                NavigationService.Navigate(new System.Uri("/Views/SpeakerPage.xaml", System.UriKind.Relative));
            }
        }
Ejemplo n.º 27
0
        private void SessionSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                SessionSpeakers sessionSpeakers = e.AddedItems[0] as SessionSpeakers;

                if (sessionSpeakers != null)
                {
                    SpeakersViewModel vm      = this.DataContext as SpeakersViewModel;
                    Session           session = sessionSpeakers.Session;
                    vm.SendSessionNavigatingMessage(session);
                    ListBox listbox = sender as ListBox;
                    listbox.SelectedIndex = -1;
                }

                NavigationService.Navigate(new System.Uri("/Views/SessionPage.xaml", System.UriKind.Relative));
            }
        }
Ejemplo n.º 28
0
        public SpeakersPage()
        {
            BindingContext = new SpeakersViewModel();

            speakersListView = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                IsPullToRefreshEnabled = true,
                ItemTemplate           = new DataTemplate(typeof(SpeakersCell)),
                SeparatorColor         = Color.Transparent
            };
            speakersListView.SetBinding(ListView.ItemsSourceProperty, nameof(SpeakersViewModel.Speakers));
            speakersListView.SetBinding(ListView.RefreshCommandProperty, nameof(SpeakersViewModel.GetSpeakersCommand));
            speakersListView.SetBinding(ListView.IsRefreshingProperty, nameof(SpeakersViewModel.IsBusy));
            speakersListView.ItemSelected += ListViewSpeakers_ItemSelected;

            Title = "Speakers";

            Content = speakersListView;
        }
Ejemplo n.º 29
0
        public SpeakersPage()
        {
            InitializeComponent();
            BindingContext = new SpeakersViewModel(Navigation);

            if (Device.OS == TargetPlatform.Android)
            {
                ListViewSpeakers.Effects.Add(Effect.Resolve("Xpirit.ListViewSelectionOnTopEffect"));
            }

            if (Device.OS == TargetPlatform.Windows || Device.OS == TargetPlatform.WinPhone)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "Refresh",
                    Icon    = "toolbar_refresh.png",
                    Command = ViewModel.ForceRefreshCommand
                });
            }
            ListViewSpeakers.ItemSelected += async(sender, e) =>
            {
                var speaker = ListViewSpeakers.SelectedItem as Speaker;
                if (speaker == null)
                {
                    return;
                }

                ContentPage destination;

                if (Device.OS == TargetPlatform.Windows || Device.OS == TargetPlatform.WinPhone)
                {
                    destination = new SpeakerDetailsPageUWP(speaker);
                }
                else
                {
                    destination = new SpeakerDetailsPage(speaker);
                }

                await NavigationService.PushAsync(Navigation, destination);

                ListViewSpeakers.SelectedItem = null;
            };
        }
Ejemplo n.º 30
0
        public SpeakersPage()
        {
            InitializeComponent();
            viewModel      = App.SimpleIoC.Resolve <SpeakersViewModel>();
            BindingContext = viewModel;


            ListSpeakers.ItemSelected += (sender, e) => {
                viewModel.CurrentSpeaker   = (Eventarin.Core.Models.Speaker)e.SelectedItem;
                ListSpeakers.HeightRequest = 470 * viewModel.Speakers.Count;
                var speakerID = 0;
                {
                    if (viewModel.CurrentSpeaker != null)
                    {
                        speakerID = viewModel.CurrentSpeaker.Id;
                        viewModel.SpeakerItemClicked.Execute(speakerID);
                    }
                }
            };
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Provides a deterministic way to delete the Speakers property.
 /// </summary>
 public static void ClearSpeakers()
 {
     _speakers.Cleanup();
     _speakers = null;
 }
Ejemplo n.º 32
0
        private void reinitializeChildViewModels()
        {
            OverviewViewModel = new OverviewViewModel(Messenger, _campService);
            OverviewViewModel.Init();

            SessionsViewModel = new SessionsViewModel(Messenger, _campService);
            SessionsViewModel.Init();

            SpeakersViewModel = new SpeakersViewModel(Messenger, _campService);
            SpeakersViewModel.Init();

            SponsorsViewModel = new SponsorsViewModel(Messenger, _campService);
            SponsorsViewModel.Init();
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Provides a deterministic way to create the Speakers property.
 /// </summary>
 public static void CreateSpeakers()
 {
     if (_speakers == null)
     {
         _speakers = new SpeakersViewModel();
     }
 }