Exemplo n.º 1
0
        public async Task <Speaker> Create(Speaker speaker)
        {
            await _speakerRepository.Add(speaker);

            await _speakerRepository.Commit();

            return(speaker);
        }
        public void CreateSpeaker([FromBody] Speaker speaker)
        {
            if (!ModelState.IsValid)
            {
                Context.Response.StatusCode = 400;
            }
            else
            {
                _speakerRepository.Add(speaker);

                string url = Url.RouteUrl("GetByIdRoute", new { id = speaker.Id.ToString() }, Request.Scheme, Request.Host.ToUriComponent());
                Context.Response.StatusCode          = 201;
                Context.Response.Headers["Location"] = url;
            }
        }
        public ActionResult Create(SpeakerViewModel speakerViewModel)
        {
            if (ModelState.IsValid)
            {
                _speakerRepository.Add(Map(speakerViewModel));
                return(RedirectToAction("Index", "Speaker"));
            }

            if (speakerViewModel.Conferences == null)
            {
                speakerViewModel.Conferences = _conferences.Select(Map).ToList();
            }

            return(View(speakerViewModel));
        }
Exemplo n.º 4
0
        private void DownloadAndSaveVideoData(VideoFeed videoFeed, string eventName)
        {
            var    hasMoreItems  = true;
            int    pageIndex     = 1;
            string lastItemTitle = string.Empty;

            do
            {
                SyndicationFeed feed = null;
                try
                {
                    using (XmlReader reader = XmlReader.Create(videoFeed.GetBuildVideoFeedUrlByPage(pageIndex, eventName)))
                    {
                        feed = SyndicationFeed.Load(reader);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                }

                if (feed != null && feed.Items != null && feed.Items.Count() > 0)
                {
                    //check last item title for match
                    if (lastItemTitle == feed.Items.Last().Title.Text)
                    {
                        break;
                    }
                    foreach (var item in feed.Items)
                    {
                        var title = CleanVideoTitle(item.Title.Text);
                        var video = _videoRepository.FindByTitle(title);
                        if (video == null)
                        {
                            video = SaveVideoData(item, videoFeed.MediaType, eventName, videoFeed.FeedYear);
                        }
                        else
                        {
                            UpdateVideoData(item, videoFeed.MediaType);
                        }

                        //Speakers
                        var creators = GetExtensionElementValue(item, "creator");
                        if (!string.IsNullOrEmpty(creators))
                        {
                            var comma         = ",".ToCharArray();
                            var presenterList = creators.Split(comma, StringSplitOptions.RemoveEmptyEntries);
                            if (presenterList.Count() > 0)
                            {
                                foreach (var presenter in presenterList)
                                {
                                    var speaker = _speakerRepository.FindByNameAndEventYear(eventName, presenter.Trim(), videoFeed.FeedYear);
                                    if (speaker == null)
                                    {
                                        speaker = _speakerRepository.Add(new Speaker()
                                        {
                                            Name = presenter.Trim(), EventYear = videoFeed.FeedYear, EventName = eventName
                                        });
                                    }
                                    var speakerVideo = _speakerVideoRepository.FindBySpeakerIdAndVideoId(speaker.Id, video.Id);
                                    if (speakerVideo == null)
                                    {
                                        _speakerVideoRepository.Add(new SpeakerVideo()
                                        {
                                            SpeakerId = speaker.Id, VideoId = video.Id
                                        });
                                    }
                                }
                            }
                        }
                    }
                    lastItemTitle = feed.Items.Last().Title.Text;
                    pageIndex++;
                }
                else
                {
                    hasMoreItems = false;
                }
            }while (hasMoreItems == true);
        }
Exemplo n.º 5
0
 public Speaker Add(Speaker newSpeaker)
 {
     return(repo.Add(newSpeaker));
 }