예제 #1
0
 public virtual ActionResult Editar(TMovie model)
 {
     model.Update();
     TMovieCategory.SaveCategories(model);
     TempData["Alerta"] = new Alert("success", "Filme alterado com sucesso");
     return(RedirectToAction("Index"));
 }
예제 #2
0
 public virtual ActionResult Excluir(int id, object diff)
 {
     TMovieCategory.Delete(x => x.Movie.Id == id);
     TMovie.Delete(id);
     TempData["Alerta"] = new Alert("success", "Filme excluído com sucesso");
     return(RedirectToAction("Index"));
 }
예제 #3
0
 public virtual ActionResult Excluir(int id, object diff)
 {
     TReservation.Delete(x => x.Id == id);
     TMovie.Delete(x => x.Id == id);
     TIten.Delete(id);
     return(RedirectToAction("Index"));
 }
예제 #4
0
        public virtual ActionResult Reservar()
        {
            var reserva = new TReservation();

            ViewBag.Movie = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(reserva));
        }
예제 #5
0
        public static void outputTime(TMovie time)
        {
            int minutes = time.PlayTime % 60;
            int hors    = (time.PlayTime - minutes) / 60;

            Console.Write("Время просмотра:{0}мин или {1}ч и {2}мин", time.PlayTime, hors, minutes);
        }
예제 #6
0
        public virtual ActionResult Editar(int id)
        {
            var itens = new TIten();

            ViewBag.Reservation = TReservation.ListAll().ToSelectList(x => x.Id, x => x.Id);
            ViewBag.Movie       = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Id);
            return(View());
        }
예제 #7
0
        public virtual ActionResult Cadastrar()
        {
            var reserva = new TReservation();

            ViewBag.Client = TClient.ListAll().ToSelectList(x => x.Id, x => x.Name);
            ViewBag.Iten   = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(reserva));
        }
예제 #8
0
        public virtual ActionResult Cadastrar()
        {
            var filme = new TMovie();

            ViewBag.EnumFormatMovie = EnumHelper.ListAll <FormatMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.EnumTypeMovie   = EnumHelper.ListAll <TypeMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.Category        = TCategory.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(filme));
        }
예제 #9
0
        public virtual ActionResult Editar(int id)
        {
            var reserva = TReservation.Load(id);

            ViewBag.Client = TClient.ListAll().ToSelectList(x => x.Id, x => x.Name);
            ViewBag.Iten   = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Name);
            ViewBag.Sale   = TSale.ListAll().ToSelectList(x => x.Id, x => x.EnumStatusSale);
            return(View(reserva));
        }
예제 #10
0
        public virtual ActionResult Editar(int id)
        {
            var filme           = TMovie.Load(id);
            var categoriasFilme = filme.TMovieCategories.Select(x => x.Category.Id).ToList();

            ViewBag.EnumFormatMovie = EnumHelper.ListAll <FormatMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.EnumTypeMovie   = EnumHelper.ListAll <TypeMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.Category        = TCategory.List(x => !categoriasFilme.Contains(x.Id)).ToSelectList(x => x.Id, x => x.Name);
            return(View(filme));
        }
예제 #11
0
 public void SaveCategories(TMovie model)
 {
     TMovieCategory.Delete(x => x.Movie.Id == model.Id);
     for (int i = 0; i < model.Categories.Length; i++)
     {
         new TMovieCategory()
         {
             Movie    = model,
             Category = TCategory.Load(model.Categories[i])
         }.Save();
     }
 }
예제 #12
0
 public void SaveIten(TReservation model)
 {
     TIten.Delete(x => x.Movie.Id == model.Id);
     if (model.Iten != null)
     {
         for (int i = 0; i < model.itensdareserva.Length; i++)
         {
             new TIten()
             {
                 Reservation = model,
                 Movie       = TMovie.Load(model.itensdareserva[i])
             }.Save();
         }
     }
 }
예제 #13
0
 public virtual ActionResult Editar(TIten model)
 {
     try
     {
         TempData["Alert"] = new Alert("success", "Seu item foi editado com sucesso");
         model.Save();
         return(RedirectToAction("Index"));
     }
     catch (SimpleValidationException ex)
     {
         ViewBag.Reservation = TReservation.ListAll().ToSelectList(x => x.Id, x => x.Id);
         ViewBag.Movie       = TMovie.ListAll().ToSelectList(x => x.Id, x => x.Id);
         return(HandleViewException(model, ex));
     }
 }
예제 #14
0
        public virtual ActionResult cliente_filmes()
        {
            List <TMovie> filmes;
            var           client       = (TClient)ViewBag.Cliente;
            var           preferencias = client.TPreferences.Select(x => x.Category.Id).ToList();

            if (preferencias.Count != 0)
            {
                filmes = TMovieCategory.List(x => preferencias.Contains(x.Category.Id)).Select(x => x.Movie).ToList();
            }
            else
            {
                filmes = TMovie.ListAll().ToList();
            }
            return(View(filmes));
        }
예제 #15
0
        public static string outputTime(TMovie time)
        {
            int    minutes = time.PlayTime % 60;
            int    hors    = (time.PlayTime - minutes) / 60;
            string temp    = $"Время просмотра: {time.PlayTime}мин или {hors}ч и {minutes}мин\n";

            if (time.PlayTime > 120)
            {
                temp += "Фильм слишком длинный";
            }
            if (time.PlayTime < 50)
            {
                temp += "Фильм слишком короткий";
            }
            return(temp);
        }
예제 #16
0
 public virtual ActionResult Cadastrar(TMovie model)
 {
     try
     {
         model.Date = DateTime.Now.GetCurrent();
         model.Save();
         TMovieCategory.SaveCategories(model);
         TempData["Alerta"] = new Alert("success", "Filme cadastrado com sucesso");
         return(RedirectToAction("Index"));
     }
     catch (SimpleValidationException ex)
     {
         ViewBag.EnumFormatMovie = EnumHelper.ListAll <FormatMovie>().ToSelectList(x => x, x => x.Description());
         ViewBag.EnumTypeMovie   = EnumHelper.ListAll <TypeMovie>().ToSelectList(x => x, x => x.Description());
         return(HandleViewException(model, ex));
     }
 }
예제 #17
0
        public virtual ActionResult Index()
        {
            var filmes = TMovie.ListAll().ToList();

            return(View(filmes));
            //var filmes2 = TMovieCategory.List(x => x.Category.Id == 5).Select(x => x.Movie);
            //TClient.List(x => x.Name == "Pedro");
            //TClient.List(x => x.Name.StartsWith("m"));
            //TClient.List(x => x.Name.EndsWith("l"));
            //TClient.List(x => x.Name.Contains("silva"));
            //TReservation.List(x => x.Client.Name.StartsWith("p"));
            //TUser.Delete(x => x.Name.EndsWith("u"));
            //TClient.Delete(x => x.Name.StartsWith("pedro") || x.Name.EndsWith("silva"));
            //TClient.List(x => Name.StartsWith("Maria") && Name.EndsWith("João"));
            //TReservation.Delete(x => x.Client.Id == cliente.Id);
            //TPreference.Delete(x => x.Client.Name.Contains("João"));
            //TMovie.List(x => x.IsActive != false && x.Stock > 0);
        }
예제 #18
0
        public void SaveMovies(TReservation model)
        {
            TIten.Delete(x => x.Reservation.Id == model.Id);

            if (model.Movies != null)
            {
                for (int i = 0; i < model.Movies.Length; i++)
                {
                    var movie = TMovie.Load(model.Movies[i]);
                    new TIten()
                    {
                        Reservation = model,
                        Movie       = movie,
                        Value       = movie.Value.Value,
                        Quantity    = model.Quantities[i]
                    }.Save();
                }
            }
        }
예제 #19
0
        public static void Main(string[] args)
        {
            TMovie       temp;
            string       endResult = "";
            StreamWriter save      = new StreamWriter("C:\\Users\\Павел\\Documents\\GitHub\\ne_spisivay\\Практика_Структуры\\Практика_Структуры\\Save\\save.txt");

            Console.Write("Введите кол-во фильмов: ");
            int a = int.Parse(Console.ReadLine());

            TMovie[] film = new TMovie[a];
            for (int i = 0; i < a; i++)
            {
                temp       = inputStruct();
                endResult += outputStruct(temp);
                endResult += outputTime(temp);

                film[i] = temp;
            }
            Console.Write(endResult);
            save.WriteLine(endResult);
            save.Close();
            Console.ReadKey();
        }
예제 #20
0
파일: Form1.cs 프로젝트: rNdm74/C-
        private void bAddMovie_Click(object sender, EventArgs e)
        {
            try
            {
                // Checks if textbox fields are valid
                int year = Convert.ToInt16(tbYearAdd.Text);

                String title = tbTitleAdd.Text;
                if (title.Trim() == String.Empty)
                    throw new ArgumentException("Please input the movie title");

                String director = tbDirectorAdd.Text;
                if (director.Trim() == String.Empty)
                    throw new ArgumentException("Please input the movie director");

                // Adds movie to the table
                TMovie movie = new TMovie(year, title, director);
                movieTable.Add(movie.year, movie);

                // Alert for confirmation
                MessageBox.Show("Movie Saved", "Add");

                // Clears the textbox fields
                tbYearAdd.Text = "";
                tbTitleAdd.Text = "";
                tbDirectorAdd.Text = "";
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Add");
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Please input the year of the movie", "Add");
            }
        }
예제 #21
0
 public static string outputStruct(TMovie output)
 {
     return($"Режисер:{output.Author}\nНазвание:{output.Name}\nГод выпуска:{output.Year}\n");
 }
예제 #22
0
        public virtual ActionResult Excluir(int id)
        {
            var filme = TMovie.Load(id);

            return(PartialView("_excluir", filme));
        }
예제 #23
0
 public static void outputStruct(TMovie output)
 {
     Console.WriteLine("Режисер:{0}\nНазвание:{1}\nГод выпуска:{2}\n", output.Author, output.Name, output.Year);
 }
예제 #24
0
 public virtual ActionResult ListarFilmesSelecionados(string term)
 {
     return(Json(TMovie.List(x => x.Name.Contains(term)).Select(a => new { label = a.Name }), JsonRequestBehavior.AllowGet));
 }
예제 #25
0
        public virtual ActionResult ListarFilmes(int id)
        {
            var filmes = TMovie.Load(id);

            return(PartialView("_listar-filmes", filmes));
        }
예제 #26
0
        public virtual ActionResult Index()
        {
            var filmes = TMovie.ListAll().ToList();

            return(View(filmes));
        }