public void Delete()
        {
            int  key;
            bool tmp = true;

            while (tmp)
            {
                PrintCMD.Film.PrintTable();
                PrintCMD.Film.DeleteMenu();
                key = PrintCMD.ReadKey();
                switch (key)
                {
                case 1:    //удаление по Id
                    int id = PrintCMD.ReadKey("Id", false);
                    Singleton.Instance.Film.Delete("Id", id.ToString());
                    break;

                case 2:    //удаление по Name
                    string tmpTitle = PrintCMD.ReadLine("Имя", false);
                    Singleton.Instance.Film.Delete("Title", tmpTitle);
                    break;

                case 0:
                    tmp = false;
                    break;
                }
            }
        }
        public void Create()
        {
            int  key;
            bool tmp = true;

            while (tmp)
            {
                PrintCMD.Actor.PrintTable();
                PrintCMD.Actor.CreateMenu();
                key = PrintCMD.ReadKey();
                switch (key)
                {
                case 1:
                    string newActor = PrintCMD.ReadLine("Новый актёр", false);
                    Singleton.Instance.Actor.Create(new Actor {
                        Name = newActor
                    });
                    break;

                case 0:
                    tmp = false;
                    break;
                }
            }
        }
Exemple #3
0
        public void Update()
        {
            int    key;
            Genre  genre;    //то что изменяем
            string tmpTitle; //новое название
            bool   tmp = true;

            while (tmp)
            {
                PrintCMD.Genre.PrintTable();
                PrintCMD.Genre.UpdateMenu();
                key = PrintCMD.ReadKey();
                switch (key)
                {
                case 1:    //изменение по Id
                    int id = PrintCMD.ReadKey("Id", false);
                    genre       = Singleton.Instance.Genre.Read("Id", id.ToString())[0];
                    tmpTitle    = PrintCMD.ReadLine(genre.Title, false);
                    genre.Title = tmpTitle;
                    Singleton.Instance.Genre.Update(genre);
                    genre = null; tmpTitle = null;
                    break;

                case 2:    //изменение по Title
                    tmpTitle    = PrintCMD.ReadLine("Название", false);
                    genre       = Singleton.Instance.Genre.Read("Title", tmpTitle)[0];
                    tmpTitle    = PrintCMD.ReadLine(genre.Title, false);
                    genre.Title = tmpTitle;
                    Singleton.Instance.Genre.Update(genre);
                    genre = null; tmpTitle = null;
                    break;

                case 0:
                    tmp = false;
                    break;
                }
            }
        }
        public void Update()
        {
            int    key;
            Actor  actor;   //то что изменяем
            string tmpName; //новое название
            bool   tmp = true;

            while (tmp)
            {
                PrintCMD.Actor.PrintTable();
                PrintCMD.Actor.UpdateMenu();
                key = PrintCMD.ReadKey();
                switch (key)
                {
                case 1:    //изменение по Id
                    int id = PrintCMD.ReadKey("Id", false);
                    actor      = Singleton.Instance.Actor.Read("Id", id.ToString())[0];
                    tmpName    = PrintCMD.ReadLine(actor.Name, false);
                    actor.Name = tmpName;
                    Singleton.Instance.Actor.Update(actor);
                    actor = null; tmpName = null;
                    break;

                case 2:    //изменение по Name
                    tmpName    = PrintCMD.ReadLine("Имя", false);
                    actor      = Singleton.Instance.Actor.Read("Name", tmpName)[0];
                    tmpName    = PrintCMD.ReadLine(actor.Name, false);
                    actor.Name = tmpName;
                    Singleton.Instance.Actor.Update(actor);
                    actor = null; tmpName = null;
                    break;

                case 0:
                    tmp = false;
                    break;
                }
            }
        }
        private void SubUpdate(Film film)//меню создания фильма
        {
            int    key;
            bool   tmp = true;
            string strTmp; //строковый параметр
            int    tmpId;  //числ параметр

            while (tmp)
            {
                PrintCMD.Film.CurrentFilm(film);
                PrintCMD.Film.SubUpdateMenu();
                key = PrintCMD.ReadKey();
                switch (key)
                {
                case 1:    //назвение
                    strTmp     = PrintCMD.ReadLine("название", false);
                    film.Title = strTmp;
                    break;

                case 2:    //жанр +
                    if (Singleton.Instance.Genre.GetAmountElements() > 0)
                    {
                        PrintCMD.Genre.PrintTable();
                        tmpId = PrintCMD.ReadKey("Id жанра", false);
                        Genre genre = Singleton.Instance.Genre.Read("Id", tmpId.ToString())[0];
                        if (!EqualsGenre(film.GenresList as List <Genre>, genre))
                        {
                            film.GenresList.Add(genre);
                        }
                    }
                    break;

                case 3:    //жанр -
                    if (film.GenresList.Count > 0)
                    {
                        tmpId = PrintCMD.ReadKey("Id жанра", false);
                        try { (film.GenresList as List <Genre>).RemoveAt(tmpId - 1); }
                        catch (Exception) { }
                    }
                    break;

                case 4:    //актёр +
                    if (Singleton.Instance.Actor.GetAmountElements() > 0)
                    {
                        PrintCMD.Actor.PrintTable();
                        tmpId = PrintCMD.ReadKey("Id актёра", false);
                        Actor actor = Singleton.Instance.Actor.Read("Id", tmpId.ToString())[0];
                        if (!EqualsActor(film.ActorsList as List <Actor>, actor))
                        {
                            film.ActorsList.Add(actor);
                        }
                    }
                    break;

                case 5:    //актёры -
                    if (film.ActorsList.Count > 0)
                    {
                        tmpId = PrintCMD.ReadKey("Id актёра", false);
                        try { (film.GenresList as List <Actor>).RemoveAt(tmpId - 1); }
                        catch (Exception) { }
                    }
                    break;

                case 6:    //рейтинг
                    strTmp      = PrintCMD.ReadLine("рейтинг", false);
                    film.Rating = Convert.ToSingle(strTmp);
                    break;

                case 7:    //просмотрено
                    film.Viewed = !film.Viewed;
                    break;

                case 8:    //готово
                    Singleton.Instance.Film.Update(film);
                    tmp = false;
                    break;

                case 0:    //назад
                    tmp = false;
                    break;
                }
            }
        }
        public void Search()
        {
            int    key;
            bool   tmp = true;
            string tmpStr;
            int    vewedKey = 0;

            while (tmp)
            {
                PrintCMD.Film.PrintTable();
                PrintCMD.Film.SearchMenu();
                key = PrintCMD.ReadKey();
                switch (key)
                {
                case 1:    //название
                    tmpStr   = PrintCMD.ReadLine("название", false);
                    vewedKey = PrintCMD.ReadKey("0 - всё \n 1 - просмотрено \n 2 - непросмотрено", false);
                    switch (vewedKey)
                    {
                    case 0:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchTableFilms("Title =", tmpStr, RepositoryFilm.ViewedType.Full));
                        break;

                    case 1:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchTableFilms("Title =", tmpStr, RepositoryFilm.ViewedType.TRUE));
                        break;

                    case 2:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchTableFilms("Title =", tmpStr, RepositoryFilm.ViewedType.FALSE));
                        break;
                    }
                    tmpStr = "";
                    PrintCMD.ReadKey();
                    break;

                case 2:    //жанр
                    PrintCMD.Genre.PrintTable();
                    int tmpIdGenre = PrintCMD.ReadKey("Id жанра", false);
                    vewedKey = PrintCMD.ReadKey("0 - всё \n 1 - просмотрено \n 2 - непросмотрено", false);
                    switch (vewedKey)
                    {
                    case 0:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchFilmsCascade(tmpIdGenre, RepositoryFilm.Subtable.Ganres, RepositoryFilm.ViewedType.Full));
                        break;

                    case 1:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchFilmsCascade(tmpIdGenre, RepositoryFilm.Subtable.Ganres, RepositoryFilm.ViewedType.TRUE));
                        break;

                    case 2:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchFilmsCascade(tmpIdGenre, RepositoryFilm.Subtable.Ganres, RepositoryFilm.ViewedType.FALSE));
                        break;
                    }
                    PrintCMD.ReadKey();
                    break;

                case 3:    //актёру
                    PrintCMD.Actor.PrintTable();
                    int tmpIdActor = PrintCMD.ReadKey("Id актёра", false);
                    vewedKey = PrintCMD.ReadKey("0 - всё \n 1 - просмотрено \n 2 - непросмотрено", false);
                    switch (vewedKey)
                    {
                    case 0:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchFilmsCascade(tmpIdActor, RepositoryFilm.Subtable.Actors, RepositoryFilm.ViewedType.Full));
                        break;

                    case 1:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchFilmsCascade(tmpIdActor, RepositoryFilm.Subtable.Actors, RepositoryFilm.ViewedType.TRUE));
                        break;

                    case 2:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchFilmsCascade(tmpIdActor, RepositoryFilm.Subtable.Actors, RepositoryFilm.ViewedType.FALSE));
                        break;
                    }
                    PrintCMD.ReadKey();
                    break;

                case 4:              //рейтингу
                    float tmpRating; //выставляемый рейтинг
                    try { tmpRating = float.Parse(PrintCMD.ReadLine("рейтинг -,-", false)); }
                    catch (Exception) { tmpRating = 0; }
                    vewedKey = PrintCMD.ReadKey("0 - всё \n 1 - просмотрено \n 2 - непросмотрено", false);
                    tmpStr   = PrintCMD.ReadLine("условие", false);
                    switch (vewedKey)
                    {
                    case 0:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchTableFilms("Rating " + tmpStr, tmpRating.ToString(), RepositoryFilm.ViewedType.Full));
                        break;

                    case 1:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchTableFilms("Rating " + tmpStr, tmpRating.ToString(), RepositoryFilm.ViewedType.TRUE));
                        break;

                    case 2:
                        PrintCMD.Film.PrintTable((Singleton.Instance.Film as RepositoryFilm).SearchTableFilms("Rating " + tmpStr, tmpRating.ToString(), RepositoryFilm.ViewedType.FALSE));
                        break;
                    }
                    PrintCMD.ReadKey();
                    break;

                case 0:
                    tmp = false;
                    break;
                }
            }
        }