Пример #1
0
        public void ShowModelMapsCorrectlyToDocsShow()
        {
            var showModel = new ShowModel
            {
                Title     = "The amazing .NET docs show",
                Url       = "https://www.twitch.tv/thedotnetdocs/7",
                ShowImage = "https://bitrebels.com/wp-content/uploads/2018/06/programming-languages-learn-header-image.jpg",
                VideoId   = 7,
                Tags      = new[] { "WinForms", "WPF" },
                Hosts     = new[] { new PersonModel {
                                        FirstName = "Dave", LastName = "Pine"
                                    } },
                Guests = new[] { new PersonModel {
                                     FirstName = "Chino", LastName = "Moreno"
                                 } }
            };

            DocsShow docsShow = _mapper.Map <DocsShow>(showModel);

            Assert.Equal(showModel.Id, docsShow.Id);
            Assert.Equal(showModel.Title, docsShow.Title);
            Assert.Equal(showModel.Url, docsShow.Url);
            Assert.Equal(showModel.ShowImage, docsShow.ShowImage);
            Assert.Equal(showModel.VideoId, docsShow.VideoId);
            Assert.Equal(showModel.Tags, docsShow.Tags);

            AssertPeopleAreEqual(showModel.Hosts, docsShow.Hosts);
            AssertPeopleAreEqual(showModel.Guests, docsShow.Guests);
        }
Пример #2
0
        static void LoadFromShow()
        {
            if (!File.Exists(_games_path))
            {
                _loopLinks = null;
                return;
            }

            Assembly myAssembly = Assembly.LoadFrom("Modules\\Games.dll");

            using (Stream stream = myAssembly.GetManifestResourceStream("Games.XmlFile.PicFile.xml"))
                using (XmlReader xmlReader = new XmlTextReader(stream))
                {
                    var param = from file in XDocument.Load(xmlReader).Element("Pics").Elements("Pic")
                                select ShowModel.CreateModel(
                        file.Attribute("id").Value,
                        file.Attribute("picsrc").Value,
                        file.Attribute("title").Value
                        );

                    try
                    {
                        foreach (var p in param)
                        {
                            _loopLinks.Add(p);
                        }
                    }
                    catch { }
                }
        }
Пример #3
0
        public ActionResult Show([Bind(Prefix = "id")] string slug)
        {
            if (string.IsNullOrWhiteSpace(slug))
                throw new ArgumentNullException("slug");

            Entry entry;
            try
            {
                entry = Services.Entry.GetBySlug(slug);
            }
            catch (Exception ex)
            {
                throw new HttpException(404, "Entry not found", ex);
            }

            var markdown = new MarkdownSharp.Markdown();
            var html = markdown.Transform(entry.Markdown);

            var model = new ShowModel
            {
                Date = entry.DateCreated.ToString("dddd, dd MMMM yyyy"),
                Slug = entry.Slug,
                Title = entry.Title,
                Html = html,
                IsCodePrettified = entry.IsCodePrettified ?? true
            };

            return View(model);
        }
Пример #4
0
 /// <summary>
 /// Converting ShowModel to ShowDtoModel
 /// </summary>
 /// <param name="showModel">Show model that will be converted</param>
 /// <param name="channelModel">Chanel model</param>
 /// <param name="genreModels">Genre models</param>
 /// <param name="seasonModels">Season models</param>
 /// <returns></returns>
 private ShowDtoModel ShowModelToDto(ShowModel showModel, ChannelModel channelModel, List <GenreModel> genreModels, List <SeasonDtoModel> seasonModels)
 {
     return(new ShowDtoModel
     {
         Name = showModel.Name,
         Id = showModel.Id,
         Aliases = showModel.Aliases,
         Actors = showModel.Actors,
         Chanel = channelModel,
         DayOfAir = showModel.DayOfAir,
         Description = showModel.Description,
         Duration = showModel.Duration,
         Genres = genreModels,
         ImageMedium = showModel.ImageMedium,
         ImageOriginal = showModel.ImageOriginal,
         ImdbId = showModel.ImdbId,
         PremiereDate = showModel.PremiereDate,
         Rating = showModel.Rating,
         Seasons = seasonModels,
         ShowUrl = showModel.ShowUrl,
         Status = showModel.Status,
         TheTvDbId = showModel.TheTvDbId,
         TimeOfAir = showModel.TimeOfAir
     });
 }
Пример #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ShowModel = await context.Shows
                        .Include(s => s.Details)
                        .Include(s => s.Episodes)
                        .FirstOrDefaultAsync(m => m.Id == id);

            var user = await GetUserModel();

            if (user != null)
            {
                if (ShowModel == null)
                {
                    return(NotFound());
                }
                if (user == null)
                {
                    return(Redirect("/"));
                }

                IsFollow = user.Favorites.Where(f => f.ShowId == id).Any();
            }

            return(Page());
        }
Пример #6
0
        public void ShowAllLayerImb(ActionMode mode, bool thisThread = false)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Image <Bgr, byte> imgLayers = ShowModel.GetLayoutImage(mModel, mode);

            if (!thisThread)
            {
                imBox.Invoke(new Action(() =>
                {
                    var x       = imBox.Image;
                    imBox.Image = imgLayers;
                    if (x != null)
                    {
                        x.Dispose();
                        x = null;
                    }
                    imBox.Refresh();
                }));
            }
            else
            {
                var x = imBox.Image;
                imBox.Image = imgLayers;
                if (x != null)
                {
                    x.Dispose();
                    x = null;
                }
                imBox.Refresh();
            }
        }
Пример #7
0
        public ActionResult CreateShow(ShowModel show)
        {
            if (show.Title == null || show.Seats <= 0 || show.Day == null)
            {
                TempData["error"] = "all fields are mandatory";

                return(View());
            }

            if (show.Seats > Constants.Rows * Constants.Seats)
            {
                TempData["error"] = "maximum number of seats is " + Constants.Rows * Constants.Seats;

                return(View());
            }

            if (showService.GetShowByDay(show.Day) != null)
            {
                TempData["error"] = "There is a show that day";

                return(View());
            }

            showService.CreateShow(show);

            return(RedirectToAction("Shows"));
        }
Пример #8
0
        public void User_Registration_Data_Null_Return_BadRequest()
        {
            ShowModel data     = null;
            var       response = userController.UserSignUp(data);

            Assert.IsType <BadRequestObjectResult>(response);
        }
Пример #9
0
        public ActionResult <Guid> Post(ShowModel ShowModel)
        {
            var movie = this.movieRepository.GetMovieById(ShowModel.MovieId);

            if (movie == null)
            {
                log.LogError($"The movie is not avilable.");
                return(BadRequest());
            }
            var venue = this.venueRepository.GetVenueById(ShowModel.VenuId);

            if (venue == null)
            {
                log.LogError($"The venue is not avilable.");
                return(BadRequest());
            }
            var newId = this.ShowRepository.CreateShow(ShowModel);

            if (newId.Equals(Guid.Empty))
            {
                log.LogError($"The venue is not empty for the given time.");
                return(BadRequest());
            }
            log.LogDebug($"new Show is create with id {newId}.");
            return(newId);
        }
Пример #10
0
        public ActionResult Show(Guid id)
        {
            var metricRepository = CurrentAccountDbContext.GetMetricRepository();
            var metric           = metricRepository.GetById(id);

            var storageContext          = CurrentAccountDbContext;
            var metricHistoryRepository = storageContext.GetMetricHistoryRepository();
            var values = metricHistoryRepository.QueryAllByMetricType(metric.ComponentId, metric.MetricTypeId)
                         .OrderByDescending(t => t.BeginDate)
                         .Take(ShowModel.LastValuesCountMax)
                         .ToList();

            var actualTimeSecs = metric.ActualTimeSecs ?? metric.MetricType.ActualTimeSecs;
            var model          = new ShowModel()
            {
                Metric          = metric,
                ConditionRed    = metric.ConditionAlarm ?? metric.MetricType.ConditionAlarm ?? "не задано",
                ConditionYellow = metric.ConditionWarning ?? metric.MetricType.ConditionWarning ?? "не задано",
                ConditionGreen  = metric.ConditionSuccess ?? metric.MetricType.ConditionSuccess ?? "не задано",
                ElseColor       = metric.ConditionElseColor ?? metric.MetricType.ConditionElseColor,
                NoSignalColor   = metric.NoSignalColor ?? metric.MetricType.NoSignalColor,
                ActualInterval  = actualTimeSecs.HasValue ? TimeSpan.FromSeconds(actualTimeSecs.Value) : (TimeSpan?)null,
                Values          = values
            };

            return(View(model));
        }
Пример #11
0
        public async Task <ShowModel> Search(ShowModel pageModel)
        {
            IEnumerable <Author> queryable = await _repository.GetAll();

            ShowModel model = pageModel;

            if (!string.IsNullOrEmpty(model.Term))
            {
                queryable = queryable.Where
                                (c => c.Id.ToString().Equals(model.Term) ||
                                c.FirstName.Equals(model.Term) ||
                                c.LastName.Equals(model.Term));
            }

            model.TotalItemCount = queryable.Count();
            model.PageSize       = (int)Math.Ceiling((double)model.TotalItemCount / model.RecordsPerPage);
            model.Page           = model.Page > model.PageSize || model.Page < 1 ? 1 : model.Page;

            var skipped = (model.Page - 1) * model.RecordsPerPage;

            queryable = queryable.Skip(skipped).Take(model.RecordsPerPage);

            model.Authors = queryable.Select(u => new AuthorModel
            {
                Id        = u.Id,
                LastName  = u.LastName,
                FirstName = u.FirstName
            }).ToList();

            return(model);
        }
Пример #12
0
        protected override async Task OnInitializedAsync()
        {
            if (ScheduleService != null && DateTimeService != null && !string.IsNullOrWhiteSpace(ShowId))
            {
                if (IsCreatingNewShow)
                {
                    var nxtThrsdy = DateTime.Today.AddDays(1).GetNextWeekday(DayOfWeek.Thursday);
                    var offset    = DateTimeService.GetCentralTimeZoneOffset(nxtThrsdy);

                    Episode = Mapper?.Map <ShowModel>(new DocsShow
                    {
                        Date = new DateTimeOffset(
                            nxtThrsdy.Year,
                            nxtThrsdy.Month,
                            nxtThrsdy.Day,
                            11, 0, 0,
                            offset)
                    }) !;
                }
                else
                {
                    _show = await ScheduleService.GetShowAsync(ShowId);

                    Episode = Mapper?.Map <ShowModel>(_show) !;
                }

                _editContext = new EditContext(Episode);
                _editContext.OnFieldChanged += OnModelChanged;
            }
        }
Пример #13
0
        public bool UpdateShow(ShowModel show)
        {
            var toUpdate = _showRepository.GetShowById(show.Id);

            if (show == null || show.Day == null || show.Seats > Constants.Rows * Constants.Seats)
            {
                return(false);
            }

            if (show.Day > DateTime.Now)
            {
                var v = GetShowByDay(show.Day);
                if (v != null && v.Id != toUpdate.Id)
                {
                    return(false);
                }
            }
            else
            {
                show.Day = toUpdate.Day;
            }

            show.Title        = show.Title ?? toUpdate.Title;
            show.Distribution = show.Distribution ?? toUpdate.Distribution;
            show.Seats        = show.Seats == 0 ? toUpdate.Seats : show.Seats;


            _showRepository.UpdateShow(show.AsDto());

            return(true);
        }
Пример #14
0
        /// <summary>
        /// Permet de créer un nouveau ShowModel.
        /// </summary>
        /// <param name="serie"></param>
        /// <returns></returns>
        private async Task <ShowModel> CreateNewShowModel(ShowInformation serie)
        {
            ShowModel showModel = new ShowModel();

            var temp = await ClientTmDb.SearchTvShowAsync(serie.Titre);

            await Task.Delay(500);

            if (temp.Results.Count > 0)
            {
                var tempSerieTrouve = temp.Results[0];

                // Récupération des informations de TmDb.
                TvShow tvShow = await ClientTmDb.GetTvShowAsync(tempSerieTrouve.Id);

                await Task.Delay(500);

                TvSeason saison = await ClientTmDb.GetTvSeasonAsync(tempSerieTrouve.Id, serie.Saison);

                await Task.Delay(500);

                TvEpisode episode = await ClientTmDb.GetTvEpisodeAsync(tempSerieTrouve.Id, serie.Saison, serie.Episode);

                showModel.TvShow = tvShow;
                showModel.TvSeasons.Add(saison);
                showModel.TvEpisodes.Add(episode);
                showModel.ShowInformation.Add(serie);
            }

            return(showModel);
        }
Пример #15
0
        private static List <ShowModel> InitShows()
        {
            var shows = new List <ShowModel>();

            var show1 = new ShowModel();

            show1.ID             = 1;
            show1.ShowName       = "Rookie Blue";
            show1.ShowCategories = new List <CategoryModel>();
            show1.ShowCategories.Add(Categories[0]);
            show1.ShowCategories.Add(Categories[1]);

            show1.BackgroundImagePath = string.Empty;

            var show2 = new ShowModel();

            show2.ID             = 2;
            show2.ShowName       = "Sleepy Hollow";
            show2.ShowCategories = new List <CategoryModel>();
            show2.ShowCategories.Add(Categories[0]);
            show2.ShowCategories.Add(Categories[2]);

            show2.BackgroundImagePath = string.Empty;


            shows.Add(show1);
            shows.Add(show2);

            return(shows);
        }
Пример #16
0
        public ActionResult Show([Bind(Prefix = "id")] string slug)
        {
            if (string.IsNullOrWhiteSpace(slug))
            {
                throw new ArgumentNullException("slug");
            }

            Entry entry;

            try
            {
                entry = Services.Entry.GetBySlug(slug);
            }
            catch (Exception ex)
            {
                throw new HttpException(404, "Entry not found", ex);
            }

            var markdown = new MarkdownSharp.Markdown();
            var html     = markdown.Transform(entry.Markdown);

            var model = new ShowModel
            {
                Date             = entry.DateCreated.ToString("dddd, dd MMMM yyyy"),
                Slug             = entry.Slug,
                Title            = entry.Title,
                Html             = html,
                IsCodePrettified = entry.IsCodePrettified ?? true
            };

            return(View(model));
        }
Пример #17
0
        public async Task ServiceTest_CheckAddOne_ExpectOk()
        {
            var date    = DateTime.Now;
            var newShow = new ShowModel
            {
                id      = 1,
                name    = "test",
                updated = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()
            };
            var factory = SetupUpsertShowRepository(null);

            _showRepository.Setup(s => s.Add(It.IsAny <IEnumerable <Show> >())).Callback <IEnumerable <Show> >(u =>
            {
                Assert.AreEqual(1, u.Count());
                Assert.AreEqual(newShow.name, u.First().Name);
                Assert.AreEqual(newShow.id, u.First().ExternalId);
                Assert.AreEqual(newShow.updated, u.First().Updated);
            }).Returns(Task.FromResult(true));

            var service = new ShowsService(factory, SetupTvMazeServer(new Dictionary <string, int> {
                { "1", (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds() }
            }, new[] { newShow }));

            await service.Sync();

            _showRepository.Verify(s => s.GetAll(), Times.Once);
            _showRepository.Verify(s => s.Add(It.IsAny <IEnumerable <Show> >()), Times.Once);
            _showRepository.Verify(s => s.Update(It.IsAny <IEnumerable <Show> >()), Times.Never);
            _showRepository.Verify(s => s.Remove(It.IsAny <IEnumerable <Show> >()), Times.Never);
        }
        private ShowModel SortAuthorsData(ShowModel paginatedProperties)
        {
            if (string.IsNullOrEmpty(paginatedProperties.SortField))
            {
                return(null);
            }
            else
            {
                if (paginatedProperties.CurrentSortField == paginatedProperties.SortField)
                {
                    ViewBag.SortOrder = paginatedProperties.CurrentSortOrder == "Asc" ? "Desc" : "Asc";
                }
                else
                {
                    ViewBag.SortOrder = "Asc";
                }
                ViewBag.SortField = paginatedProperties.SortField;
            }

            var propertyInfo = typeof(AuthorModel).GetProperty(ViewBag.SortField);

            paginatedProperties.Authors = ViewBag.SortOrder == "Asc"
          ?
                                          paginatedProperties.Authors.OrderBy(s => propertyInfo.GetValue(s, null))
          :
                                          paginatedProperties.Authors.OrderByDescending(s => propertyInfo.GetValue(s, null));

            return(paginatedProperties);
        }
Пример #19
0
        public void Given_Admin_Registration_Request_Null_Should_Return_BadRequest()
        {
            ShowModel data     = null;
            var       response = adminController.AdminSignUp(data);

            Assert.IsType <BadRequestObjectResult>(response);
        }
Пример #20
0
        public IActionResult Show()
        {
            string    id    = HttpContext.Request.Query["id"].FirstOrDefault();
            string    ss    = HttpContext.Request.Query["ss"].FirstOrDefault();
            ShowModel model = new ShowModel(id, ss);

            return(View(model));
        }
Пример #21
0
        public ActionResult Show(string id)
        {
            var model = new ShowModel {
                Uri = pdfStorage.UriFor(id)
            };

            return(View(model));
        }
        public ActionResult Show(string fileId)
        {
            var model = new ShowModel {
                Uri = fileStore.UriFor(fileId)
            };

            return(View(model));
        }
        public ActionResult Show(string imageId)
        {
            var model = new ShowModel {
                Uri = _imageStore.UriFor(imageId)
            };

            return(View(model));
        }
Пример #24
0
        public IActionResult Show(string id)
        {
            var model = new ShowModel {
                Uri = _store.UriFor(id)
            };

            return(View(model));
        }
Пример #25
0
        void timer_Tick(object sender, EventArgs e)
        {
            _showModel = _loopLink.GetNext();

            this.ID     = _showModel.ID;
            this.Title  = _showModel.Title;
            this.ImgSrc = _showModel.PicSrc;
        }
Пример #26
0
        public ShowView CreateView(ShowModel model)
        {
            Type modelType = model.GetType();

            if (customTypeFactories.ContainsKey(modelType))
            {
                CreateViewHandler handler = customTypeFactories[modelType];
                return(handler(model));
            }

            if (model is TokenModel)
            {
                return(null);
            }
            if (model is ShowSettings)
            {
                return(null);
            }
            if (model is ShowZoneModel)
            {
                ShowZoneModel zoneModel = model as ShowZoneModel;
                //if (zoneModel.IsMap)
                //{
                //    return new ShowMapView(zoneModel);
                //}
                //else
                {
                    return(new ShowZoneView(zoneModel));
                }
            }
            if (model is ShowTextModel)
            {
                return(new ShowTextView(model as ShowTextModel));
            }
            if (model is ShowImageModel)
            {
                return(new ShowImageView(model as ShowImageModel));
            }
            //if (model is ShowArrowModel)
            //{
            //    return new ShowArrowView(model as ShowArrowModel);
            //}
            if (model is ShowSlidePartModel)
            {
                return(new ShowSlidePartView(model as ShowSlidePartModel));
            }
            if (model is ShowObjectModel)
            {
                //Model is just a generic ShowObject
                return(new ShowObjectView(model as ShowObjectModel));
            }
            if (model is ShowModel)
            {
                return(new ShowView(model));
            }

            return(null);
        }
Пример #27
0
        private void showEdit_Click(object sender, EventArgs e)
        {
            if (!showNrTicketsText.Text.All(Char.IsDigit))
            {
                StatusLabel.Text = "Invalid number of tickets selected!";
                return;
            }
            if (showIDText.Text == "")
            {
                StatusLabel.Text = "Error! No ID chosen!";
                return;
            }
            if (showTitleText.Text == "")
            {
                StatusLabel.Text = "Error! No title chosen!";
                return;
            }
            if (showDistributionText.Text == "")
            {
                StatusLabel.Text = "Error! No distribution chosen!";
                return;
            }
            if (showNrTicketsText.Text == "")
            {
                StatusLabel.Text = "Error! No number of tickets chosen!";
                return;
            }
            if (!(showGenreSelection.SelectedIndex == 0 || showGenreSelection.SelectedIndex == 1))
            {
                StatusLabel.Text = "Error! No genre chosen!";
                return;
            }
            if (!showServices.isID(Convert.ToInt32(showIDText.Text)))
            {
                StatusLabel.Text = "Error! The show with the given ID does not exist!";
            }
            ShowModel model = new ShowModel();

            model.setID(Convert.ToInt32(showIDText.Text));
            model.setTitle(showTitleText.Text);
            model.setDistribution(showDistributionText.Text);
            model.setNumberOfTickets(Convert.ToInt32(showNrTicketsText.Text));
            if (showGenreSelection.SelectedIndex == 0)
            {
                model.setGenre("Opera");
            }
            else
            {
                model.setGenre("Ballet");
            }
            model.setDate(showDatePicker.Value.Date);
            showServices.update(model);
            StatusLabel.Text = "Show edited!";

            //refresh
            ShowRefresh();
            showGenreSelection.SelectedIndex = -1;
        }
Пример #28
0
        public async Task <ActionResult> Show(string id, IAzureBlobStorage storage)
        {
            var model = new ShowModel {
                Uri = await storage.UriFor(id)
            };

            //return View(model);
            return(PartialView("_Image"));
        }
Пример #29
0
        public ActionResult Show(string id)
        {
            var model = new ShowModel()
            {
                Uri = imageStore.GetUri(id)
            };

            return(View(model));
        }
Пример #30
0
        public void OnBtnShowModelClick()
        {
            ShowModel showModel = new ShowModel();

            showModel.ViewModel.ModelAssociations = ModelAssociations;
            showModel.ViewModel.ModelClasses      = ModelClasses;

            showModel.ShowDialog();
        }
Пример #31
0
        /// <summary>
        /// Insert new show,
        /// </summary>
        /// <param name="show">The populated data model to insert. Throws ArgumentNullException on null.</param>
        public void Insert(ShowModel show)
        {
            if (show == null)
            {
                throw new ArgumentNullException("show");
            }

            collection.InsertOne(show);
        }
Пример #32
0
		public ActionResult Index()
		{
			var model = new ShowModel();
			var about = Services.About.GetAll().FirstOrDefault();
			if (about != null)
			{
				model.Name = about.Name;
				model.Title = about.Title;
				model.ImageUrl = about.ImageUrl;
				model.Content = new Markdown().Transform(about.Content);
			}

			return View(model);
		}
Пример #33
0
 /// <summary>
 /// ���ñ�ǩ��ʾ����
 /// </summary>
 /// <param name="showModel">ShowDeviceָʾ�豸,TwoBitShowDevice��λ����</param>
 public void SetFunctionType(ShowModel showModel)
 {
     ((Protocal)this.Com.Encoder).FormatType = (byte)showModel;
 }