예제 #1
0
        public async Task <IActionResult> Put(string moniker, int id, [FromBody] SpeakerModel model)
        {
            try
            {
                var speaker = _repo.GetSpeaker(id);
                if (speaker == null)
                {
                    return(NotFound("Can't find a speaker with that id"));
                }

                if (speaker.Camp.Moniker != moniker)
                {
                    return(BadRequest("Speaker isn't part of that camp"));
                }

                if (speaker.User.UserName == this.User.Identity.Name) //Loggedin User
                {
                    return(Forbid());                                 //You can't amend speaker to anyone other than yourself.
                }

                _mapper.Map(model, speaker);                //map from model to speaker
                // speaker is updated so differences will now be saved
                if (await _repo.SaveAllAsync())
                {
                    return(Ok(_mapper.Map <SpeakerModel>(speaker)));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception thrown while updating speaker: {ex}");
            }
            return(BadRequest("Could not update speaker"));
        }
        public async Task <IActionResult> Post(string moniker, [FromBody] SpeakerModel model)
        {
            try
            {
                var camp = _repository.GetCampByMoniker(moniker);
                if (camp == null)
                {
                    return(BadRequest("Could not find camp"));
                }

                var speaker = _mapper.Map <Speaker>(model);
                speaker.Camp = camp;

                _repository.Add(speaker);

                if (await _repository.SaveAllAsync())
                {
                    var url = Url.Link("SpeakerGet", new { moniker = camp.Moniker, id = speaker.Id });
                    return(Created(url, _mapper.Map <SpeakerModel>(speaker)));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception thrown while adding speaker: {ex}");
            }

            return(BadRequest("Could not add new speaker"));
        }
        public async Task <IActionResult> Post(string moniker, [FromBody] SpeakerModel model)
        {
            try
            {
                var camp = _repository.GetCampByMoniker(moniker);            // get the camp
                if (camp == null)
                {
                    return(BadRequest("Could not find camp"));
                }

                var speaker = _mapper.Map <Speaker>(model);  // get the speaker. convert the passed in model to our Speaker Entities using automapper
                speaker.Camp = camp;                         // assign camp to the speaker - relationship

                // Authentication
                var campUser = await _userMgr.FindByNameAsync(this.User.Identity.Name);  // find the camp user and return it. Ensured that the user logged in is the same user we have

                if (campUser != null)
                {
                    speaker.User = campUser;

                    _repository.Add(speaker);                                                            //  add speaker to repository

                    if (await _repository.SaveAllAsync())                                                // save to database
                    {
                        var url = Url.Link("SpeakGet", new { moniker = camp.Moniker, id = speaker.Id }); // generate a url for the new object
                        return(Created(url, _mapper.Map <SpeakerModel>(speaker)));                       // new speaker is created
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"++++++++++++++++++++ Exception thrown while adding speaker +++++++++++++++++++++++++ {ex}");
            }
            return(BadRequest("Could not add new speaker"));
        }
예제 #4
0
        public async Task <IActionResult> Post(string moniker, [FromBody] SpeakerModel model)
        {
            try
            {
                // We are adding the speaker to the camp.
                var camp = _repo.GetCampByMoniker(moniker);
                if (camp == null)
                {
                    return(BadRequest("Could not find camp"));
                }

                var speaker = _mapper.Map <Speaker>(model);
                speaker.Camp = camp;

                var campUser = await _userMgr.FindByNameAsync(this.User.Identity.Name);

                if (campUser != null)
                {
                    speaker.User = campUser;

                    _repo.Add(speaker);
                    if (await _repo.SaveAllAsync())
                    {
                        var url = Url.Link("SpeakerGet", new { moniker = camp.Moniker, id = speaker.Id });
                        return(Created(url, _mapper.Map <SpeakerModel>(speaker)));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception thrown while adding speaker: {ex}");
            }
            return(BadRequest("Could not add new speaker"));
        }
예제 #5
0
        public async void GetSpeakersForEvent_Test()
        {
            APIService   srv      = new APIService();
            SpeakerModel model    = new SpeakerModel();
            EventModel   evtmodel = new EventModel();

            evtmodel.CommandModel.SessionToken = "bfc223c67931041556d324e25ee98cd0818dc6370486291d925127b1f5cd90ef";
            evtmodel.CommandModel.Action       = "GetOpenEvents";

            var res = await srv.GetEvents(evtmodel.CommandModel);

            if (res.Status == "OK" && res.Data != null)
            {
                Dictionary <string, string> p = new Dictionary <string, string>();
                p.Add("eventId", string.Format("'{0}'", res.Data.FirstOrDefault().Id));

                model.CommandModel.SessionToken = "bfc223c67931041556d324e25ee98cd0818dc6370486291d925127b1f5cd90ef";
                model.CommandModel.ServiceName  = "Speaker";
                model.CommandModel.Action       = "GetSpeakersForEvent";
                model.CommandModel.Parameters   = p;

                var r = await srv.GetSpeakersForEvent(model.CommandModel);

                Assert.True(r.Status == "OK" && r.Data != null);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
        public async Task <IActionResult> Put(string moniker, int id, [FromBody] SpeakerModel model)
        {
            try
            {
                var speaker = _repository.GetSpeaker(id);     // get existing speaker
                if (speaker == null)
                {
                    return(NotFound());
                }
                // check that the speaker is part of a moniker/camp
                if (speaker.Camp.Moniker != moniker)
                {
                    return(BadRequest("Speaker and camp do not match"));
                }

                // Ensure that the user logged in, is the same user we have in the system
                if (speaker.User.UserName == this.User.Identity.Name)
                {
                    return(Forbid());
                }

                _mapper.Map(model, speaker);    // map source to destination (model to speaker)

                if (await _repository.SaveAllAsync())
                {
                    return(Ok(_mapper.Map <SpeakerModel>(speaker)));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"+++++++++++++++++++++ Exception thrown while updating speaker +++++++++++++++++++++++ {ex}");
            }
            return(BadRequest("Could not update speaker"));
        }
예제 #7
0
        private static async Task <SpeakersResults> GetSpeakers(string eventID)
        {
            APIService   srv              = new APIService();
            SpeakerModel model            = new SpeakerModel();
            Dictionary <string, string> p = new Dictionary <string, string>();

            p.Add("eventId", string.Format("'{0}'", eventID));

            model.CommandModel.SessionToken = await App.GetUsersSession();

            model.CommandModel.ServiceName = "Speaker";
            model.CommandModel.Action      = "GetSpeakersForEvent";
            model.CommandModel.Parameters  = p;

            SpeakersResults result = null;
            var             cache  = BlobCache.UserAccount;
            var             cachedSpeakersPromise = cache.GetAndFetchLatest(
                "speakers",
                () => srv.GetSpeakersForEvent(model.CommandModel),
                offset =>
            {
                TimeSpan elapsed = DateTimeOffset.Now - offset;
                return(elapsed > new TimeSpan(hours: 0, minutes: 10, seconds: 0));
            });

            cachedSpeakersPromise.Subscribe(subscribedSpeakers =>
            {
                result = subscribedSpeakers;
            });

            result = await cachedSpeakersPromise.FirstOrDefaultAsync();

            return(result);
        }
예제 #8
0
        public async Task <IActionResult> Put(string moniker, int id, [FromBody] SpeakerModel model)
        {
            try
            {
                var speaker = _repository.GetSpeaker(id);
                if (speaker == null)
                {
                    return(NotFound());
                }
                if (speaker.Camp.Moniker != moniker)
                {
                    return(BadRequest("Speaker and Camp do not match"));
                }

                if (speaker.User.UserName != this.User.Identity.Name)
                {
                    return(Forbid());
                }

                _mapper.Map(model, speaker);

                if (await _repository.SaveAllAsync())
                {
                    return(Ok(_mapper.Map <SpeakerModel>(speaker)));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception thrown while updating speaker: {ex}");
            }

            return(BadRequest("Could not update speaker"));
        }
예제 #9
0
        public async Task <SpeakerModel> GetSpeakerByIdAsync(int IdSpeaker)
        {
            SpeakerModel speaker = await DbContext.Speaker.Select(
                s => new SpeakerModel
            {
                IdSpeaker      = s.IdSpeaker,
                FirstName      = s.FirstName,
                SecondName     = s.SecondName,
                FirstLastName  = s.FirstLastName,
                SecondLastName = s.SecondLastName,
                TwitterLink    = s.TwitterLink,
                LinkedInLink   = s.LinkedInLink,
                PhotoLink      = s.PhotoLink
            })
                                   .FirstOrDefaultAsync(s => s.IdSpeaker == IdSpeaker);

            speaker.Sessions = await DbContext.SpeakerHasSession.Select(
                s => new SpeakerHasSessionModel
            {
                IdSpeaker      = s.IdSpeaker,
                FirstName      = s.IdSpeakerNavigation.FirstName,
                SecondName     = s.IdSpeakerNavigation.SecondName,
                FirstLastName  = s.IdSpeakerNavigation.FirstLastName,
                SecondLastName = s.IdSpeakerNavigation.SecondLastName,

                IdSession        = s.IdSession,
                Name             = s.IdSessionNavigation.Name,
                StartDate        = s.IdSessionNavigation.StartDate,
                NameSessionLevel = s.IdSessionNavigation.IdSessionLevelNavigation.Name,
                NameSessionType  = s.IdSessionNavigation.IdSessionTypeNavigation.Name
            }
                ).Where(s => s.IdSpeaker == IdSpeaker).ToListAsync();

            return(speaker);
        }
예제 #10
0
        public async Task <bool> AddSpeakerAsync(SpeakerModel speakerModel)
        {
            _context.Speaker.Add(speakerModel);
            var saveResult = await _context.SaveChangesAsync();

            return(saveResult == 1);
        }
예제 #11
0
        public async Task <ActionResult <SpeakerModel> > Put(int id, SpeakerModel model)
        {
            try
            {
                var oldSpeaker = await _repository.GetSpeakerAsync(id);

                if (oldSpeaker == null)
                {
                    return(BadRequest($"Could not find speaker for {id}"));
                }

                _mapper.Map(model, oldSpeaker);

                if (await _repository.SaveChangesAsync())
                {
                    return(_mapper.Map <SpeakerModel>(oldSpeaker));
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }

            return(BadRequest());
        }
예제 #12
0
        public async Task <IActionResult> Post(string moniker, [FromBody] SpeakerModel model)
        {
            try
            {
                var camp = campRepository.GetCampByMoniker(moniker);
                if (camp == null)
                {
                    return(BadRequest($"Could not find camp {moniker}"));
                }

                var speaker = mapper.Map <Speaker>(model);
                speaker.Camp = camp;

                campRepository.Add(speaker);

                if (await campRepository.SaveAllAsync())
                {
                    var url = Url.Link("GetSpeaker", new { moniker = camp.Moniker, id = speaker.Id });
                    return(Created(url, mapper.Map <SpeakerModel>(speaker)));
                }
                else
                {
                    logger.LogWarning("Could not save speaker to the database.");
                }
            }
            catch (Exception ex)
            {
                logger.LogError($"Exception was thrown while adding a speaker for camp {moniker}: {ex}");
            }

            return(BadRequest("Could not add new speaker."));
        }
예제 #13
0
        public async Task <IActionResult> Put(string moniker, int id, [FromBody] SpeakerModel model)
        {
            try
            {
                var camp = campRepository.GetCampByMoniker(moniker);
                if (camp == null)
                {
                    return(BadRequest($"Could not find camp {moniker}."));
                }

                var speaker = campRepository.GetSpeaker(id);
                if (speaker == null)
                {
                    return(NotFound());
                }
                if (speaker.Camp.Moniker != moniker)
                {
                    return(BadRequest());
                }

                mapper.Map(model, speaker);

                if (await campRepository.SaveAllAsync())
                {
                    return(Ok(mapper.Map <SpeakerModel>(speaker)));
                }
            }
            catch (Exception ex)
            {
                logger.LogError($"Excpetion was thrown while updating speaker: {ex}");
            }
            return(BadRequest("Could not update speaker."));
        }
예제 #14
0
        static void VoiceEncodingOperation(SpeakerModel speakerModel)
        {
            var voiceEncodingService = new VoiceEncodingService(speakerModel);

            voiceEncodingService.VideoEncoded += OnEncoded;
            voiceEncodingService.VideoEncoded += OnEncodedSendEmail;

            voiceEncodingService.Operation();
        }
예제 #15
0
        public SpeakerDetailsViewModel(SpeakerModel speakerModel)
        {
            this.SpeakerModel = speakerModel;

            if (!string.IsNullOrWhiteSpace(speakerModel.BlogUrl))
            {
                this.FollowItems.Add(
                    new MenuItem
                {
                    Name      = speakerModel.BlogUrl.StripUrlForDisplay(),
                    Parameter = speakerModel.BlogUrl,
                    Icon      = "icon_blog.png"
                });
            }

            if (!string.IsNullOrWhiteSpace(speakerModel.TwitterUrl))
            {
                var twitterValue = speakerModel.TwitterUrl.CleanUpTwitter();

                this.FollowItems.Add(
                    new MenuItem
                {
                    Name      = $"@{twitterValue}",
                    Parameter = "https://twitter.com/" + twitterValue,
                    Icon      = "icon_twitter.png"
                });
            }

            if (!string.IsNullOrWhiteSpace(speakerModel.FacebookProfileName))
            {
                var profileName        = speakerModel.FacebookProfileName.GetLastPartOfUrl();
                var profileDisplayName = profileName;
                if (long.TryParse(profileName, out _))
                {
                    profileDisplayName = "Facebook";
                }

                this.FollowItems.Add(
                    new MenuItem
                {
                    Name      = profileDisplayName,
                    Parameter = "https://facebook.com/" + profileName,
                    Icon      = "icon_facebook.png"
                });
            }

            if (!string.IsNullOrWhiteSpace(speakerModel.LinkedInUrl))
            {
                this.FollowItems.Add(
                    new MenuItem
                {
                    Name      = "LinkedIn",
                    Parameter = speakerModel.LinkedInUrl.StripUrlForDisplay(),
                    Icon      = "icon_linkedin.png"
                });
            }
        }
예제 #16
0
        public void UpdateSpeaker(SpeakerModel speakerModel)
        {
            Speaker speaker = _untoldContext.Speaker.Find(speakerModel.SpeakerId);

            speaker.FirstName   = speakerModel.FirstName;
            speaker.LastName    = speakerModel.LastName;
            speaker.Nationality = speakerModel.Nationality;
            speaker.Rating      = speakerModel.Rating;
            _untoldContext.SaveChanges();
        }
예제 #17
0
        private SpeakerModel AddSelfLinkTo(SpeakerModel speaker)
        {
            var selfLink = ModelFactory.CreateLink(Url, "self", "Speaker", new { speakerId = speaker.Id });

            speaker.Links = new List <LinkModel> {
                selfLink
            };

            return(speaker);
        }
예제 #18
0
        public SpeakerDetailsPage(SpeakerModel speakerModel)
            : this()
        {
            this.SpeakerModel = speakerModel;

            this.speakerImage.Error += (source, arg) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    this.speakerFullNameLabel.FontSize *= 2;
                    this.speakerTitleLabel.FontSize    *= 2;
                });
            };
        }
예제 #19
0
        public async Task <ActionResult <SpeakerModel> > GetTalksByMonikerAsync(int id)
        {
            try
            {
                var ListCapms = await campRepository.GetSpeakerAsync(id);

                SpeakerModel campModels = mapper.Map <SpeakerModel>(ListCapms);
                return(campModels);
            }
            catch (Exception)
            {
                return(this.StatusCode(500, "Database Failure"));
            }
        }
예제 #20
0
        public void InsertSpeaker(SpeakerModel speakerModel)
        {
            Speaker speaker = new Speaker()
            {
                FirstName   = speakerModel.FirstName,
                LastName    = speakerModel.LastName,
                Nationality = speakerModel.Nationality,
                Rating      = speakerModel.Rating,
                ImagePath   = speakerModel.ImagePath
            };

            _untoldContext.Speaker.Add(speaker);
            _untoldContext.SaveChanges();
        }
예제 #21
0
        private void RegisterHandoff(SpeakerModel speakerModel)
        {
            var userInfo = new NSMutableDictionary
            {
                {
                    new NSString("Url"),
                    new NSString(
                        speakerModel.GetAppLink().AppLinkUri.AbsoluteUri)
                }
            };

            var keywords = new NSMutableSet <NSString>(
                new NSString(speakerModel.FirstName),
                new NSString(speakerModel.LastName));

            if (speakerModel.Talks != null)
            {
                foreach (var session in speakerModel.Talks)
                {
                    keywords.Add(new NSString(session.Title));
                }
            }

            this.activity.Keywords   = new NSSet <NSString>(keywords);
            this.activity.WebPageUrl = NSUrl.FromString(speakerModel.GetWebUrl());

            this.activity.EligibleForHandoff = false;

            this.activity.AddUserInfoEntries(userInfo);

            // Provide context
            var attributes =
                new CSSearchableItemAttributeSet($"{AboutThisApp.PackageName}.speaker")
            {
                Keywords =
                    keywords.ToArray()
                    .Select(
                        k =>
                        k.ToString())
                    .ToArray(),
                Url = NSUrl.FromString(
                    speakerModel
                    .GetAppLink()
                    .AppLinkUri
                    .AbsoluteUri)
            };

            this.activity.ContentAttributeSet = attributes;
        }
예제 #22
0
        public Task Execute(SpeakerModel entity)
        {
            this.activity?.Invalidate();

            this.activity = new NSUserActivity($"{AboutThisApp.PackageName}.speaker")
            {
                Title = entity.FullName
            };

            this.RegisterHandoff(entity);

            this.activity.BecomeCurrent();

            return(Task.CompletedTask);
        }
        public async Task GetSpeakerAsyncSuccess()
        {
            var testSpeaker = GetTestSpeakerResponse();

            var apiClientStub = new Mock <IApiClient>();

            apiClientStub.Setup(a => a.GetSpeakerAsync(1))
            .ReturnsAsync(testSpeaker);

            var model = new SpeakerModel(apiClientStub.Object);

            var result = await model.OnGet(1);

            Assert.IsType <PageResult>(result);
        }
예제 #24
0
        public SpeakerModel GetSpeakerById(int id)
        {
            Speaker      speaker      = _untoldContext.Speaker.Where(s => s.SpeakerId == id).FirstOrDefault();
            SpeakerModel speakerModel = new SpeakerModel()
            {
                SpeakerId   = speaker.SpeakerId,
                FirstName   = speaker.FirstName,
                LastName    = speaker.LastName,
                Nationality = speaker.Nationality,
                Rating      = (float)speaker.Rating,
                ImagePath   = speaker.ImagePath
            };

            return(speakerModel);
        }
예제 #25
0
        /// <summary>
        /// 新しい話者設定値を適用する。
        /// </summary>
        /// <param name="setting">新しい話者設定値</param>
        /// <returns>エラーメッセージ、もしくはnull</returns>
        public static string ApplySpeakerSetting(SpeakerSettingModel setting)
        {
            Speaker = setting;
            try
            {
                // ボイスライブラリを読み込む
                if (0 < Speaker.VoiceDbName.Length)
                {
                    // 指定されたボイスライブラリを読み込む
                    string voice_db_name = Speaker.VoiceDbName;
                    AitalkWrapper.LoadVoice(voice_db_name);

                    // 話者が指定されているときはその話者を選択する
                    if (0 < Speaker.SpeakerName.Length)
                    {
                        AitalkWrapper.Parameter.CurrentSpeakerName = Speaker.SpeakerName;
                    }
                }
                else
                {
                    // 未指定の場合、初めに見つけたものを読み込む
                    string voice_db_name = AitalkWrapper.VoiceDbList.FirstOrDefault() ?? "";
                    AitalkWrapper.LoadVoice(voice_db_name);
                }

                // 話者パラメータの初期値を記憶する
                DefaultSpeakerParameter = new SpeakerModel
                {
                    Volume        = AitalkWrapper.Parameter.VoiceVolume,
                    Speed         = AitalkWrapper.Parameter.VoiceSpeed,
                    Pitch         = AitalkWrapper.Parameter.VoicePitch,
                    Emphasis      = AitalkWrapper.Parameter.VoiceEmphasis,
                    PauseMiddle   = AitalkWrapper.Parameter.PauseMiddle,
                    PauseLong     = AitalkWrapper.Parameter.PauseLong,
                    PauseSentence = AitalkWrapper.Parameter.PauseSentence
                };

                return(null);
            }
            catch (AitalkException ex)
            {
                return(ex.Message);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        public void AddVoiceSamples(string samplesSpeaker, List <byte[]> samples)
        {
            if (string.IsNullOrEmpty(samplesSpeaker))
            {
                throw new ArgumentNullException(nameof(samplesSpeaker));
            }

            if (samples == null || !samples.Any())
            {
                throw new ArgumentException(nameof(samples));
            }

            foreach (var sample in samples)
            {
                ComparisonCore.Instance.LoadVoiceSample(samplesSpeaker, sample);
            }

            var dataSpeakers = ComparisonCore.Instance.Speakers.Select(x =>
            {
                var dataModel = new SpeakerModel()
                {
                    Id       = x.Id,
                    Name     = x.Name,
                    Features = x.Samples.Select(y => new FeaturesModel()
                    {
                        Id = y.Id, Features = string.Join(";", y.MelFrequency)
                    }).ToList()
                };

                return(dataModel);
            });

            foreach (var dataSpeaker in dataSpeakers)
            {
                var speaker = dataSpeaker.Id != null?_uow.Speakers.GetWithFeatures(dataSpeaker.Id) : null;

                if (speaker != null)
                {
                    _uow.Speakers.Update(dataSpeaker);
                }
                else
                {
                    _uow.Speakers.Create(dataSpeaker);
                }
            }

            _uow.SaveChanges();
        }
예제 #27
0
        public SpeakerModel GetSpeakerByName(string fname, string lname)
        {
            Speaker speaker = _untoldContext.Speaker.Where(s => s.FirstName.ToLower() == fname.ToLower() && s.LastName.ToLower() == lname.ToLower()).FirstOrDefault();

            SpeakerModel speakerModel = new SpeakerModel()
            {
                SpeakerId   = speaker.SpeakerId,
                FirstName   = speaker.FirstName,
                LastName    = speaker.LastName,
                Nationality = speaker.Nationality,
                Rating      = (float)speaker.Rating,
                ImagePath   = speaker.ImagePath
            };

            return(speakerModel);
        }
        public IEnumerator TestCreateSpeakerModel()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to TestCreateSpeakerModel...");
            SpeakerModel speakerModel = null;
            string       speakerId    = "";

            MemoryStream ms = new MemoryStream();
            FileStream   fs = File.OpenRead(wavFilePath);

            fs.CopyTo(ms);
            service.CreateSpeakerModel(
                callback: (DetailedResponse <SpeakerModel> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "CreateSpeakerModel result: {0}", response.Response);
                speakerModel = response.Result;
                Assert.IsNotNull(speakerModel);
                Assert.IsNotNull(speakerModel.SpeakerId);
                Assert.IsNull(error);
                speakerId = speakerModel.SpeakerId;
            },
                speakerName: "speakerNameUnity",
                audio: ms
                );

            while (speakerModel == null)
            {
                yield return(null);
            }

            bool isComplete = false;

            service.DeleteSpeakerModel(
                callback: (DetailedResponse <object> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "DeleteSpeakerModel result: {0}", response.Response);
                Assert.IsTrue(response.StatusCode == 204);
                Assert.IsNull(error);
                isComplete = true;
            },
                speakerId: speakerId
                );

            while (!isComplete)
            {
                yield return(null);
            }
        }
예제 #29
0
        private static SpeakerModel GetSpeakerFrom(SqlDataReader reader)
        {
            var speaker = new SpeakerModel
            {
                Id              = reader.GetInt32(0),
                Name            = reader.GetString(1),
                TwitterProfile  = reader.IsDBNull(3) ? null : reader.GetString(3),
                LinkedinProfile = reader.IsDBNull(4) ? null : reader.GetString(4),
                Website         = reader.IsDBNull(5) ? null : reader.GetString(5),
                Biography       = reader.GetString(6),
                Image           = reader.GetString(7),
                City            = reader.GetString(8),
                Country         = reader.GetString(9),
                Links           = new List <LinkModel>()
            };

            return(speaker);
        }
예제 #30
0
        public async Task <IActionResult> Speaker(string id)
        {
            var model = new SpeakerModel();

            model.Speaker = _speakerService.Value.GetById(id);

            if (model.Speaker == null)
            {
                return(RedirectToAction("Index"));
            }

            var workshops = _workshopService.Value
                            .GetAll()
                            .Where(x => x.Speaker.Id.Equals(model.Speaker.Id, StringComparison.InvariantCultureIgnoreCase))
                            .ToList();

            model.Workshops = new List <WorkshopModel>();

            foreach (var workshop in workshops)
            {
                var ticketsLeft = workshop.MaxTickets - (await AppFactory.TicketService.Value.GetWorkshopTicketsAsync(workshop.Id)).Count;
                if (ticketsLeft < 0)
                {
                    ticketsLeft = 0;
                }

                model.Workshops.Add(new WorkshopModel
                {
                    Workshop        = workshop,
                    TicketsLeft     = ticketsLeft,
                    ShowSpeakerInfo = false
                });
            }

            model.Topics = _topicService.Value
                           .GetAll()
                           .Where(x => x.Speakers.Select(x1 => x1.Id).Any(x2 => x2.Equals(model.Speaker.Id, StringComparison.InvariantCultureIgnoreCase)))
                           .OrderBy(x => x.Timetable.TimeStart)
                           .ToList();

            return(View(model));
        }