예제 #1
0
        /// <summary>
        /// Изменить выбранный м/ф и все связанные данные
        /// </summary>
        /// <param name="value">Конечное значение м/ф</param>
        private void ChangeSelectedCartoon(Cartoon value)
        {
            if (IsDesignTime)
            {
                _selectedCartoon = value;
                NotifyOfPropertyChange(() => SelectedCartoon);
                return;
            }

            CartoonIndexes.CurrentIndex = value == null
                                ? -1
                                : Cartoons.IndexOf(value);
            NotifyOfPropertyChange(() => CanSelectNextCartoon);
            NotifyOfPropertyChange(() => CanSelectPreviousCartoon);

            if (_selectedCartoon == value)
            {
                return;
            }

            IdList.CartoonId         = value?.CartoonId ?? 0;
            SelectedCartoonVoiceOver = null;
            ChangeSelectedSeason(null);


            if (value == null)
            {
                _selectedCartoon = null;
                NotifyCartoonData();
            }
            else
            {
                LoadData();
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Pick your content type: \n 1. Movie \n 2.Tv Series \n 3.Cartoons \n 4.Docummentary");
            int input = Convert.ToInt32(Console.ReadLine());

            switch (input)
            {
            case 1:
                Movie movie = new Movie();
                movie.DisplayContent();
                break;

            case 2:
                MovieSeries movieSeries = new MovieSeries();
                movieSeries.DisplayContent();
                break;

            case 3:
                Cartoons caroon = new Cartoons();
                caroon.DisplayContent();
                break;

            case 4:
                Docummentary docummentary = new Docummentary();
                docummentary.DisplayContent();
                break;

            default:
                Console.WriteLine("Wrong input!");
                break;
            }
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Duration,Year,FilmStudiosId")] Cartoons cartoons)
        {
            if (id != cartoons.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cartoons);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CartoonsExists(cartoons.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FilmStudiosId"] = new SelectList(_context.FilmStudios, "Id", "Name", cartoons.FilmStudiosId);
            return(View(cartoons));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Duration,Year,FilmStudiosId")] Cartoons cartoons)
        {
            int counter = 0;

            foreach (var a in _context.Cartoons)
            {
                if (a.Name == cartoons.Name)

                {
                    counter++; break;
                }
            }
            if (counter != 0)
            {
                ModelState.AddModelError("Name", "Такий мультик вже існує");
                ViewData["FilmStudiosId"] = new SelectList(_context.FilmStudios, "Id", "Name", cartoons.FilmStudiosId);
                return(View(cartoons));
            }
            else
            {
                if (cartoons.Year < 1900 || cartoons.Year > 2020)
                {
                    ModelState.AddModelError("Year", "Некоректне значення");
                    ViewData["FilmStudiosId"] = new SelectList(_context.FilmStudios, "Id", "Name", cartoons.FilmStudiosId);
                    return(View(cartoons));
                }
                else
                {
                    if (cartoons.Duration < 0)
                    {
                        ModelState.AddModelError("Duration", "Некоректне значення");
                        ViewData["FilmStudiosId"] = new SelectList(_context.FilmStudios, "Id", "Name", cartoons.FilmStudiosId);
                        return(View(cartoons));
                    }
                    else
                    {
                        if (ModelState.IsValid)
                        {
                            _context.Add(cartoons);
                            await _context.SaveChangesAsync();

                            return(RedirectToAction(nameof(Index)));
                        }
                        ViewData["FilmStudiosId"] = new SelectList(_context.FilmStudios, "Id", "Name", cartoons.FilmStudiosId);
                        return(View(cartoons));
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Действие при старте просмотра
        /// </summary>
        public async void Start()
        {
            if (CanStart is false)
            {
                return;
            }

            var cartoonsCount = Cartoons.Count(c => c.Checked);

            if (GeneralSettings.WatchingInRow is true &&
                cartoonsCount > 1)
            {
                WinMan.ShowDialog(new DialogViewModel(
                                      "На данный момент нельзя смотреть подряд эпизоды, если выбрано более одного мультсериала."
                                      , DialogType.INFO));
                return;
            }

            ((MainViewModel)Parent).WindowState = WindowState.Minimized;

            StartBrowser();

            await Task.Run(StartWatch);
        }
예제 #6
0
        /// <summary>
        /// Загрузка из базы данных всех необходимых данных
        /// </summary>
        private void LoadData()
        {
            // --Начальная, когда ни один мульсериал не выбран
            if (_selectedCartoon == null)
            {
                LoadCartoonList();

                // --При загруженных с конструктора данных мультсериала
                if (IdList.CartoonId > 0)
                {
                    var tempId = 0;
                    if (_selectedCartoon != null)
                    {
                        tempId = _selectedCartoon.CartoonId;
                    }

                    _selectedCartoon = _cartoons.FirstOrDefault(c => c.CartoonId == IdList.CartoonId);

                    if (_selectedCartoon == null)
                    {
                        IdList.CartoonId = tempId;
                        _selectedCartoon = _cartoons.FirstOrDefault(c => c.CartoonId == IdList.CartoonId);
                    }

                    CartoonIndexes.CurrentIndex = Cartoons.IndexOf(_selectedCartoon);
                    LoadData();
                }
                else
                {
                    SelectedCartoon = _cartoons.FirstOrDefault();
                }

                NotifyCartoonData();
                return;
            }

            // --При выборе мультсериала
            if (_selectedSeason == null)
            {
                LoadCartoonVoiceOverList();
                LoadSeasonList();

                // установка значения выбранному мультфильму при смене его на другой
                _selectedCartoon            = _cartoons.FirstOrDefault(c => c.CartoonId == IdList.CartoonId);
                CartoonIndexes.CurrentIndex = Cartoons.IndexOf(_selectedCartoon);
                NotifyCartoonData();

                if (IdList.SeasonId > 0)
                {
                    var tempId = 0;
                    if (_selectedSeason != null)
                    {
                        tempId = _selectedSeason.CartoonSeasonId;
                    }

                    _selectedSeason = _seasons.FirstOrDefault(cs => cs.CartoonSeasonId == IdList.SeasonId);

                    if (_selectedSeason == null)
                    {
                        IdList.SeasonId = tempId;
                        _selectedSeason = _seasons.FirstOrDefault(cs => cs.CartoonSeasonId == IdList.SeasonId);
                    }

                    SeasonIndexes.CurrentIndex = Seasons.IndexOf(_selectedSeason);
                    LoadData();
                }
                else
                {
                    SelectedSeason = _seasons.FirstOrDefault();
                }

                NotifySeasonData();
                return;
            }

            // --При выборе сезона
            if (_selectedEpisode == null)
            {
                LoadEpisodeList();

                _selectedSeason            = _seasons.FirstOrDefault(cs => cs.CartoonSeasonId == IdList.SeasonId);
                SeasonIndexes.CurrentIndex = Seasons.IndexOf(_selectedSeason);
                NotifySeasonData();

                if (IdList.EpisodeId > 0)
                {
                    var tempId = 0;
                    if (_selectedEpisode != null)
                    {
                        tempId = _selectedEpisode.CartoonEpisodeId;
                    }

                    _selectedEpisode = _episodes.FirstOrDefault(ce => ce.CartoonEpisodeId == IdList.EpisodeId);

                    if (_selectedEpisode == null)
                    {
                        IdList.EpisodeId = tempId;
                        _selectedEpisode = _episodes.FirstOrDefault(ce => ce.CartoonEpisodeId == IdList.EpisodeId);
                    }

                    EpisodeIndexes.CurrentIndex = Episodes.IndexOf(_selectedEpisode);
                    LoadData();
                }
                else
                {
                    SelectedEpisode = _episodes.FirstOrDefault();
                }

                NotifyEpisodeData();
                return;
            }

            // --При выборе эпизода
            LoadEpisodeVoiceOverList();
            _selectedEpisode            = _episodes.FirstOrDefault(ce => ce.CartoonEpisodeId == IdList.EpisodeId);
            EpisodeIndexes.CurrentIndex = Episodes.IndexOf(_selectedEpisode);
            NotifyEpisodeData();
        }
예제 #7
0
        public async Task <IActionResult> Import(IFormFile fileExcel)
        {
            if (ModelState.IsValid)
            {
                if (fileExcel != null)
                {
                    using (var stream = new FileStream(fileExcel.FileName, FileMode.Create))
                    {
                        await fileExcel.CopyToAsync(stream);

                        using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled))
                        {
                            // var lang = _context.BookGenres.Include(b => b.Book).Include(b => b.Book.Language).ToList();
                            //перегляд усіх листів (в даному випадку категорій)
                            foreach (IXLWorksheet worksheet in workBook.Worksheets)
                            {
                                //worksheet.Name - назва категорії. Пробуємо знайти в БД, якщо відсутня, то створюємо нову
                                Awards newaw;
                                var    c = (from aw in _context.Awards
                                            where aw.Name.Contains(worksheet.Name)
                                            select aw).ToList();
                                if (c.Count > 0)
                                {
                                    newaw = c[0];
                                }
                                else
                                {
                                    newaw      = new Awards();
                                    newaw.Name = worksheet.Name;
                                    _context.Awards.Add(newaw);
                                }
                                foreach (IXLRow row in worksheet.RowsUsed().Skip(1))
                                {
                                    try {
                                        Cartoons cartoon = new Cartoons();
                                        int      counter = 0;
                                        foreach (var ca in _context.Cartoons)
                                        {
                                            if (ca.Name == row.Cell(1).Value.ToString())
                                            {
                                                counter++; cartoon = ca; break;
                                            }
                                        }
                                        if (counter > 0)
                                        {
                                            int count = 0;
                                            foreach (var award in _context.CartoonAwards)
                                            {
                                                if ((cartoon.Id == award.CartoonsId) && (newaw.Id == award.AwardsId))
                                                {
                                                    count++; break;
                                                }
                                            }
                                            if (count > 0)
                                            {
                                                goto link1;// якщо такф нагорода вже існує, переходимо до наступного рядка
                                            }
                                            else
                                            {
                                                CartoonAwards cartaw = new CartoonAwards();
                                                cartaw.Cartoons = cartoon;
                                                cartaw.Awards   = newaw;
                                                try
                                                {
                                                    cartaw.Year = Convert.ToInt32(row.Cell(2).Value);
                                                    if (cartaw.Year <= cartoon.Year)
                                                    {
                                                        goto link1;
                                                    }
                                                }
                                                catch { goto link1; }
                                                _context.CartoonAwards.Add(cartaw);
                                                goto link1;// переходимо до наступного рядка, бо вже маємо інформацію про нагороду цього мульта
                                            }
                                        }
                                        else
                                        {
                                            cartoon      = new Cartoons();
                                            cartoon.Name = row.Cell(1).Value.ToString();

                                            try
                                            {
                                                cartoon.Year = Convert.ToInt32(row.Cell(3).Value);
                                                if (cartoon.Year <= 0)
                                                {
                                                    goto link1;
                                                }
                                                cartoon.Duration = Convert.ToInt32(row.Cell(4).Value);
                                            }
                                            catch { goto link1; }
                                            FilmStudios filmstudio = new FilmStudios();
                                            counter = 0;
                                            foreach (var fst in _context.FilmStudios)
                                            {
                                                if (fst.Name == row.Cell(5).Value.ToString())
                                                {
                                                    counter++; filmstudio = fst; break;
                                                }
                                            }
                                            if (counter > 0)
                                            {
                                                cartoon.FilmStudios = filmstudio;
                                            }
                                            else
                                            {
                                                Countries country = new Countries();
                                                counter = 0;
                                                foreach (var co in _context.Countries)
                                                {
                                                    if (co.Name == row.Cell(6).Value.ToString())
                                                    {
                                                        counter++; country = co; break;
                                                    }
                                                }
                                                if (counter > 0)
                                                {
                                                    filmstudio.CountriesId = country.Id;
                                                }
                                                else
                                                {
                                                    country      = new Countries();
                                                    country.Name = row.Cell(6).Value.ToString();
                                                    _context.Countries.Add(country);
                                                    filmstudio.CountriesId = country.Id;
                                                }

                                                // BookGenres bg = new BookGenres();
                                                // cartoon.FilmStudios = filmstudio;
                                                filmstudio.Name = row.Cell(5).Value.ToString();
                                                _context.FilmStudios.Add(filmstudio);
                                            }
                                            _context.Cartoons.Add(cartoon);
                                            CartoonAwards cartaw = new CartoonAwards();
                                            cartaw.Cartoons = cartoon;
                                            cartaw.Awards   = newaw;
                                            try
                                            {
                                                cartaw.Year = Convert.ToInt32(row.Cell(2).Value);
                                                if (cartaw.Year <= cartoon.Year)
                                                {
                                                    goto link1;
                                                }
                                            }
                                            catch { goto link1; }
                                            _context.CartoonAwards.Add(cartaw);
                                        }
                                    }

                                    catch (Exception e)
                                    {
                                        throw new InvalidOperationException("Дані в файлі некоректні", e);
                                        // ModelState.AddModelError("", "Username or Password is wrong.");

                                        //logging самостійно :)
                                    }


                                    link1 :;
                                    await _context.SaveChangesAsync();
                                }
                                //Genres newgen;
                                //var c = (from gen in _context.Genres
                                //         where gen.Name.Contains(worksheet.Name)
                                //         select gen).ToList();
                                //if (c.Count > 0)
                                //{
                                //    newgen = c[0];
                                //}
                                //else
                                //{
                                //    newgen = new Genres();
                                //    newgen.Name = worksheet.Name;
                                //    _context.Genres.Add(newgen);
                                //}
                                //перегляд усіх рядків
                            }
                        }
                    }
                }
            }
            return(RedirectToAction(nameof(Index)));
        }