Ejemplo n.º 1
0
        public NewsModel getMoviesToNews()
        {
            NewsModel model = new NewsModel {
                MoviesList = new List <Movies_ttl>()
            };
            var cass = new CassandraDatabase();

            Cassandra.RowSet movies = cass.getAllDataFromTable("movies_ttl2");

            foreach (var movie in movies)
            {
                Movies_ttl tmpMovie = new Movies_ttl
                {
                    Id      = movie["id"].ToString(),
                    Title   = movie["title"].ToString(),
                    Date    = movie["release_date"].ToString(),
                    Genere  = movie["genere"].ToString(),
                    Runtime = movie["runtime"].ToString(),
                    Rating  = movie["rating"].ToString(),
                    Summary = movie["summary"].ToString(),
                    RawImg  = movie["img_base64"].ToString(),
                    Price   = movie["price"].ToString()
                };
                model.MoviesList.Add(tmpMovie);
            }
            return(model);
        }
Ejemplo n.º 2
0
        public void CassandraNotification()
        {
            CartModel model = new CartModel();

            model.Movies = new List <MovieCart>();

            string actualCart = redisGetValue(this.HttpContext.Session.Id, 2);
            var    moviesId   = actualCart.Split(";");

            foreach (var movieId in moviesId)
            {
                MovieCart movie = new HttpRequestHelper().getMovieToCart(movieId);
                model.Movies.Add(movie);
            }

            double totalPrice = 0.0;

            foreach (var movie in model.Movies)
            {
                try
                {
                    totalPrice += Convert.ToDouble(movie.Price);
                }
                catch
                {
                    continue;
                }
            }

            var cass = new CassandraDatabase();

            cass.insertNotification(this.CurrentUser.Name, totalPrice.ToString());
        }
Ejemplo n.º 3
0
        public IActionResult Notification()
        {
            NotificationModel model = new NotificationModel();

            model.Notifications = new List <Notification>();
            var    cass      = new CassandraDatabase();
            string condition = "where user_login = "******"'" + this.CurrentUser.Name + "'";

            Cassandra.RowSet notifications = cass.getAllDataFromTableWithCondition("notification", condition);

            foreach (var notification in notifications)
            {
                Notification tmpNotification = new Notification
                {
                    User    = notification["user_login"].ToString(),
                    Time    = notification["added_time"].ToString().Split("+")[0],
                    Message = notification["message"].ToString(),
                };
                model.Notifications.Add(tmpNotification);
            }

            return(View(model));
        }