public async Task <IActionResult> GetPictures(int id)
        {
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (Request.Query.ContainsKey("id"))
                {
                    id = Convert.ToInt32((Request.Query.FirstOrDefault(p => p.Key == "id").Value));
                }


                var pictures_ = (from pictures in db.Set <Pictures>()
                                 join picture_writer in db.Set <Picture_writer>()
                                 on pictures.Id_picture equals picture_writer.Id_picture
                                 where picture_writer.Id_writer.Equals(id)
                                 select new
                {
                    Id_picture = pictures.Id_picture,
                    Picture_name = pictures.Picture_name,
                    Picture_link = pictures.Picture_link,
                    Picture_type = pictures.Picture_type,
                }).ToList();

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (pictures_ == null)
                {
                    return(NotFound());
                }
                return(Ok(pictures_));
            }
        }
        public async Task <IActionResult> GetPlaces(string place_name = "", string name = "")
        {
            //using (LiteraryTourismContext db = new LiteraryTourismContext())
            //{
            if (Request.Query.ContainsKey("place_name"))
            {
                place_name = (Request.Query.FirstOrDefault(p => p.Key == "place_name").Value);
            }
            if (Request.Query.ContainsKey("name"))
            {
                name = (Request.Query.FirstOrDefault(p => p.Key == "name").Value);
            }

            var places_ = (from places in db.Set <Places>()
                           join place_writer in db.Set <Place_writer>()
                           on places.Id_place equals place_writer.Id_place
                           join writers in db.Set <Writers>()
                           on place_writer.Id_writer equals writers.Id_writer
                           where places.Place_name.Contains(place_name) &&
                           writers.Full_name.Contains(name)
                           select new
            {
                Id_place = places.Id_place,
                Place_name = places.Place_name,
                Place_description = places.Place_description,
                Place_rating = places.Place_rating,
                Place_address = places.Place_address,
                Latitude = places.Latitude,
                Longitude = places.Longitude,
                Relation_description = place_writer.Relation_description,
                Id_writer = writers.Id_writer,
                Full_name = writers.Full_name,
                Date_of_birth = writers.Date_of_birth,
                Date_of_death = writers.Date_of_death,
                Place_of_birth = writers.Place_of_birth,
                Place_of_death = writers.Place_of_death,
                Biography = writers.Biography
            }).ToList();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (places_ == null)
            {
                return(NotFound());
            }
            return(Ok(places_));


            //}
        }
        public async Task <IActionResult> GetWorks(string work_name = "", string name = "")
        {
            Works _works = new Works();

            if (Request.Query.ContainsKey("work_name"))
            {
                work_name = (Request.Query.FirstOrDefault(p => p.Key == "work_name").Value);
            }
            if (Request.Query.ContainsKey("name"))
            {
                name = (Request.Query.FirstOrDefault(p => p.Key == "name").Value);
            }
            //using (LiteraryTourismContext db = new LiteraryTourismContext())
            //{
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var works_ = (from works in db.Set <Works>()
                          join genre_of_literature in db.Set <Genres_of_literature>()
                          on works.Id_genre equals genre_of_literature.Id_genre
                          join writers in db.Set <Writers>()
                          on works.Id_writer equals writers.Id_writer
                          where writers.Full_name.Contains(name) &&
                          works.Work_name.Contains(work_name)
                          select new
            {
                Id_work = works.Id_work,
                Id_writer = works.Id_writer,
                Id_genre = works.Id_genre,
                Work_name = works.Work_name,
                Work_link = works.Work_link,
                Work_description = works.Work_description,
                Work_rating = works.Work_rating,
                genre_name = genre_of_literature.Genre_name,
                Id_Writer = writers.Id_writer,
                Full_name = writers.Full_name,
                Date_of_birth = writers.Date_of_birth,
                Date_of_death = writers.Date_of_death,
                Place_of_birth = writers.Place_of_birth,
                Place_of_death = writers.Place_of_death,
                Biography = writers.Biography
            }).ToList();

            if (works_ == null)
            {
                return(NotFound());
            }

            return(Ok(works_));
            //}
        }
        public async Task <IActionResult> GetRoutes(string route_name = "", string name = "", string nick = "")
        {
            Movies _movies = new Movies();

            if (Request.Query.ContainsKey("route_name"))
            {
                route_name = (Request.Query.FirstOrDefault(p => p.Key == "route_name").Value);
            }
            if (Request.Query.ContainsKey("name"))
            {
                name = (Request.Query.FirstOrDefault(p => p.Key == "name").Value);
            }
            if (Request.Query.ContainsKey("nick"))
            {
                nick = (Request.Query.FirstOrDefault(p => p.Key == "nick").Value);
            }
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var routes_ = (from routes in db.Set <Routes>()
                               join users in db.Set <Users>()
                               on routes.Id_user equals users.Id_user
                               join writers in db.Set <Writers>()
                               on routes.Id_writer equals writers.Id_writer
                               where writers.Full_name.Contains(name) &&
                               routes.Route_name.Contains(route_name) &&
                               users.Nick.Contains(nick)
                               select new
                {
                    Id_route = routes.Id_route,
                    Route_name = routes.Route_name,
                    Id_user = routes.Id_user,
                    Id_writer = routes.Id_writer,
                    Date = routes.Date,
                    Route_description = routes.Route_description,
                    Route_rating = routes.Route_rating,
                    Full_name = writers.Full_name,
                    Nick = users.Nick
                }).ToList();

                if (routes_ == null)
                {
                    return(NotFound());
                }

                return(Ok(routes_));
            }
        }
Exemple #5
0
        public async Task <IActionResult> GetMovies(string movie_title = "", string name = "")
        {
            Movies _movies = new Movies();

            if (Request.Query.ContainsKey("movie_title"))
            {
                movie_title = (Request.Query.FirstOrDefault(p => p.Key == "movie_title").Value);
            }
            if (Request.Query.ContainsKey("name"))
            {
                name = (Request.Query.FirstOrDefault(p => p.Key == "name").Value);
            }
            //using (LiteraryTourismContext db = new LiteraryTourismContext())
            //{
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var movies_ = (from movies in db.Set <Movies>()
                           join movie_writer in db.Set <Movie_writer>()
                           on movies.Id_movie equals movie_writer.Id_movie
                           join writers in db.Set <Writers>()
                           on movie_writer.Id_writer equals writers.Id_writer
                           where writers.Full_name.Contains(name) &&
                           movies.Movie_title.Contains(movie_title)
                           select new
            {
                Id_movie = movies.Id_movie,
                Movie_title = movies.Movie_title,
                Movie_link = movies.Movie_link,
                Year_of_issue = movies.Year_of_issue,
                Movie_description = movies.Movie_description,
                Movie_rating = movies.Movie_rating,
                Id_writer = writers.Id_writer,
                Full_name = writers.Full_name,
                Date_of_birth = writers.Date_of_birth,
                Date_of_death = writers.Date_of_death,
                Place_of_birth = writers.Place_of_birth,
                Place_of_death = writers.Place_of_death,
                Biography = writers.Biography
            }).ToList();

            if (movies_ == null)
            {
                return(NotFound());
            }

            return(Ok(movies_));
            // }
        }
        public async Task <IActionResult> GetRouteSpectacle(int id)
        {
            //using (LiteraryTourismContext db = new LiteraryTourismContext())
            //{
            if (Request.Query.ContainsKey("id"))
            {
                id = Convert.ToInt32((Request.Query.FirstOrDefault(p => p.Key == "id").Value));
            }


            var spectacles_ = (from spectacles in db.Set <Spectacles>()
                               join route_spectacle in db.Set <Route_spectacle>()
                               on spectacles.Id_spectacle equals route_spectacle.Id_spectacle
                               join theaters in db.Set <Theaters>()
                               on spectacles.Id_theater equals theaters.Id_theater
                               where route_spectacle.Id_route.Equals(id)
                               select new
            {
                Id_spectacle = spectacles.Id_spectacle,
                Id_theater = spectacles.Id_theater,
                Spectacle_title = spectacles.Spectacle_title,
                Director = spectacles.Director,
                Spectacle_type = spectacles.Spectacle_type,
                Spectacle_link = spectacles.Spectacle_link,
                Spectacle_description = spectacles.Spectacle_description,
                Spectacle_rating = spectacles.Spectacle_rating,
                Id_Theater = theaters.Id_theater,
                Theater_name = theaters.Theater_name,
                Theater_site = theaters.Theater_site,
                Theater_description = theaters.Theater_description,
                Theater_address = theaters.Theater_address,
                Latitude = theaters.Latitude,
                Longitude = theaters.Longitude
            }).ToList();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (spectacles_ == null)
            {
                return(NotFound());
            }
            return(Ok(spectacles_));


            //}
        }
Exemple #7
0
        public async Task <IActionResult> GetWriter(string name = "")
        {
            Writers writer = new Writers();

            if (Request.Query.ContainsKey("name"))
            {
                name = (Request.Query.FirstOrDefault(p => p.Key == "name").Value);
            }
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var writersdb = (from writers in db.Set <Writers>()
                                 where writers.Full_name.Contains(name)
                                 select writers).ToList();

                if (writersdb == null)
                {
                    return(NotFound());
                }

                return(Ok(writersdb));
            }
        }
Exemple #8
0
 public async Task <IActionResult> PostMark([FromBody] Mark_of_movie mark)
 {
     using (LiteraryTourismContext db = new LiteraryTourismContext())
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var mark_ = (from Mark in db.Set <Mark_of_movie>()
                      where Mark.Id_movie.Equals(mark.Id_movie) &&
                      Mark.Id_user.Equals(mark.Id_user)
                      select new
         {
             Id_mark = Mark.Id_mark
         }).ToList();
         if (mark_.Count != 0)
         {
             mark.Id_mark         = mark_[0].Id_mark;
             db.Entry(mark).State = EntityState.Modified;
             try
             {
                 await db.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
             }
         }
         else
         {
             db.Mark_of_movie.Add(mark);
             await db.SaveChangesAsync();
         }
         return(NoContent());
     }
 }
        public async Task <IActionResult> GetUser(string log = " ", string pass = "******")
        {
            Users user = new Users();

            if (Request.Query.ContainsKey("log") && Request.Query.ContainsKey("pass"))
            {
                log  = (Request.Query.FirstOrDefault(p => p.Key == "log").Value);
                pass = (Request.Query.FirstOrDefault(p => p.Key == "pass").Value);
            }
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var user1 = (from users in db.Set <Users>()
                             where users.Login == log &&
                             users.Password == pass
                             select users).ToList();

                if (user1 == null)
                {
                    return(NotFound());
                }

                return(Ok(user1));
            }
        }
        public async Task <IActionResult> GetMuseums(string museum_name = "", string name = "")
        {
            Museums _museums = new Museums();

            if (Request.Query.ContainsKey("museum_name"))
            {
                museum_name = (Request.Query.FirstOrDefault(p => p.Key == "museum_name").Value);
            }
            if (Request.Query.ContainsKey("name"))
            {
                name = (Request.Query.FirstOrDefault(p => p.Key == "name").Value);
            }
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var museums_ = (from museums in db.Set <Museums>()
                                join museum_writer in db.Set <Museum_writer>()
                                on museums.Id_museum equals museum_writer.Id_museum
                                join writers in db.Set <Writers>()
                                on museum_writer.Id_writer equals writers.Id_writer
                                where writers.Full_name.Contains(name) &&
                                museums.Museum_name.Contains(museum_name)
                                select new { Id_museum = museums.Id_museum, Museum_name = museums.Museum_name,
                                             Museum_site = museums.Museum_site, Museum_description = museums.Museum_description,
                                             Museum_rating = museums.Museum_rating, Museum_address = museums.Museum_address,
                                             Latitude = museums.Latitude, Longitude = museums.Longitude,
                                             Id_writer = writers.Id_writer, Full_name = writers.Full_name,
                                             Date_of_birth = writers.Date_of_birth, Date_of_death = writers.Date_of_death,
                                             Place_of_birth = writers.Place_of_birth, Place_of_death = writers.Place_of_death,
                                             Biography = writers.Biography }).ToList();

                if (museums_ == null)
                {
                    return(NotFound());
                }

                return(Ok(museums_));
            }
        }
        public async Task <IActionResult> GetComments(int id)
        {
            //using (LiteraryTourismContext db = new LiteraryTourismContext())
            //{
            if (Request.Query.ContainsKey("id"))
            {
                id = Convert.ToInt32((Request.Query.FirstOrDefault(p => p.Key == "id").Value));
            }


            var comments_ = (from comments in db.Set <Comment_movie>()
                             join users in db.Set <Users>()
                             on comments.Id_user equals users.Id_user
                             where comments.Id_movie.Equals(id)
                             select new
            {
                Id_comment = comments.Id_comment,
                Id_movie = comments.Id_movie,
                Id_user = comments.Id_user,
                Date = comments.Date,
                Time = comments.Time,
                Comment = comments.Comment,
                Edit_flag = comments.Edit_flag,
                Nick = users.Nick
            }).ToList();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (comments_ == null)
            {
                return(NotFound());
            }
            return(Ok(comments_));


            // }
        }
Exemple #12
0
        public async Task <IActionResult> GetRouteMovie(int id)
        {
            //using (LiteraryTourismContext db = new LiteraryTourismContext())
            //{
            if (Request.Query.ContainsKey("id"))
            {
                id = Convert.ToInt32((Request.Query.FirstOrDefault(p => p.Key == "id").Value));
            }


            var movies_ = (from movies in db.Set <Movies>()
                           join route_movie in db.Set <Route_movie>()
                           on movies.Id_movie equals route_movie.Id_movie
                           where route_movie.Id_route.Equals(id)
                           select new
            {
                Id_movie = movies.Id_movie,
                Movie_title = movies.Movie_title,
                Movie_link = movies.Movie_link,
                Year_of_issue = movies.Year_of_issue,
                Movie_description = movies.Movie_description,
                Movie_rating = movies.Movie_rating
            }).ToList();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (movies_ == null)
            {
                return(NotFound());
            }
            return(Ok(movies_));


            //}
        }
        public async Task <IActionResult> GetRouteMuseum(int id)
        {
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (Request.Query.ContainsKey("id"))
                {
                    id = Convert.ToInt32((Request.Query.FirstOrDefault(p => p.Key == "id").Value));
                }


                var museums_ = (from museums in db.Set <Museums>()
                                join route_museum in db.Set <Route_museum>()
                                on museums.Id_museum equals route_museum.Id_museum
                                where route_museum.Id_route.Equals(id)
                                select new
                {
                    Id_museum = museums.Id_museum,
                    Museum_name = museums.Museum_name,
                    Museum_site = museums.Museum_site,
                    Museum_description = museums.Museum_description,
                    Museum_rating = museums.Museum_rating,
                    Museum_address = museums.Museum_address,
                    Latitude = museums.Latitude,
                    Longitude = museums.Longitude
                }).ToList();

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (museums_ == null)
                {
                    return(NotFound());
                }
                return(Ok(museums_));
            }
        }
Exemple #14
0
        public async Task <IActionResult> GetRoutePlace(int id)
        {
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (Request.Query.ContainsKey("id"))
                {
                    id = Convert.ToInt32((Request.Query.FirstOrDefault(p => p.Key == "id").Value));
                }


                var places_ = (from places in db.Set <Places>()
                               join route_place in db.Set <Route_place>()
                               on places.Id_place equals route_place.Id_place
                               where route_place.Id_route.Equals(id)
                               select new
                {
                    Id_place = places.Id_place,
                    Place_name = places.Place_name,
                    Place_description = places.Place_description,
                    Place_rating = places.Place_rating,
                    Place_address = places.Place_address,
                    Latitude = places.Latitude,
                    Longitude = places.Longitude
                }).ToList();

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (places_ == null)
                {
                    return(NotFound());
                }
                return(Ok(places_));
            }
        }
Exemple #15
0
        public async Task <IActionResult> GetSpectacles(string theater_name = "", string spectacle_title = "", string writer_name = "")
        {
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if ((Request.Query.ContainsKey("theater_name")))
                {
                    theater_name = (Request.Query.FirstOrDefault(p => p.Key == "theater_name").Value);
                }
                if ((Request.Query.ContainsKey("spectacle_title")))
                {
                    spectacle_title = (Request.Query.FirstOrDefault(p => p.Key == "spectacle_title").Value);
                }
                if ((Request.Query.ContainsKey("writer_name")))
                {
                    writer_name = (Request.Query.FirstOrDefault(p => p.Key == "writer_name").Value);

                    var spectacles_ = (from spectacles in db.Set <Spectacles>()
                                       join theaters in db.Set <Theaters>()
                                       on spectacles.Id_theater equals theaters.Id_theater
                                       join spectacle_writer in db.Set <Spectacle_writer>()
                                       on spectacles.Id_spectacle equals spectacle_writer.Id_spectacle
                                       join writers in db.Set <Writers>()
                                       on spectacle_writer.Id_writer equals writers.Id_writer
                                       where theaters.Theater_name.Contains(theater_name) &&
                                       spectacles.Spectacle_title.Contains(spectacle_title) &&
                                       writers.Full_name.Contains(writer_name)
                                       select new
                    {
                        Id_spectacle = spectacles.Id_spectacle,
                        Id_theater = spectacles.Id_theater,
                        Spectacle_title = spectacles.Spectacle_title,
                        Director = spectacles.Director,
                        Spectacle_type = spectacles.Spectacle_type,
                        Spectacle_link = spectacles.Spectacle_link,
                        Spectacle_description = spectacles.Spectacle_description,
                        Spectacle_rating = spectacles.Spectacle_rating,
                        Id_Theater = theaters.Id_theater,
                        Theater_name = theaters.Theater_name,
                        Theater_site = theaters.Theater_site,
                        Theater_description = theaters.Theater_description,
                        Theater_address = theaters.Theater_address,
                        Latitude = theaters.Latitude,
                        Longitude = theaters.Longitude,
                    }).Distinct().ToList();

                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }

                    if (spectacles_ == null)
                    {
                        return(NotFound());
                    }
                    return(Ok(spectacles_));
                }
                else
                {
                    var spectacles_ = (from spectacles in db.Set <Spectacles>()
                                       join theaters in db.Set <Theaters>()
                                       on spectacles.Id_theater equals theaters.Id_theater
                                       where theaters.Theater_name.Contains(theater_name) &&
                                       spectacles.Spectacle_title.Contains(spectacle_title)
                                       select new
                    {
                        Id_spectacle = spectacles.Id_spectacle,
                        Id_theater = spectacles.Id_theater,
                        Spectacle_title = spectacles.Spectacle_title,
                        Director = spectacles.Director,
                        Spectacle_type = spectacles.Spectacle_type,
                        Spectacle_link = spectacles.Spectacle_link,
                        Spectacle_description = spectacles.Spectacle_description,
                        Spectacle_rating = spectacles.Spectacle_rating,
                        Id_Theater = theaters.Id_theater,
                        Theater_name = theaters.Theater_name,
                        Theater_site = theaters.Theater_site,
                        Theater_description = theaters.Theater_description,
                        Theater_address = theaters.Theater_address,
                        Latitude = theaters.Latitude,
                        Longitude = theaters.Longitude,
                    }).Distinct().ToList();

                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }

                    if (spectacles_ == null)
                    {
                        return(NotFound());
                    }
                    return(Ok(spectacles_));
                }
            }
        }
        public async Task <IActionResult> GetTheaters(string theater_name = "", string spectacle_title = "")
        {
            using (LiteraryTourismContext db = new LiteraryTourismContext())
            {
                if (Request.Query.ContainsKey("theater_name"))
                {
                    theater_name = (Request.Query.FirstOrDefault(p => p.Key == "theater_name").Value);
                }
                if (Request.Query.ContainsKey("spectacle_title"))
                {
                    spectacle_title = (Request.Query.FirstOrDefault(p => p.Key == "spectacle_title").Value);

                    var theaters_ = (from theaters in db.Set <Theaters>()
                                     join spectacles in db.Set <Spectacles>()
                                     on theaters.Id_theater equals spectacles.Id_theater
                                     where theaters.Theater_name.Contains(theater_name) &&
                                     spectacles.Spectacle_title.Contains(spectacle_title)
                                     select new
                    {
                        Id_theater = theaters.Id_theater,
                        Theater_name = theaters.Theater_name,
                        Theater_site = theaters.Theater_site,
                        Theater_description = theaters.Theater_description,
                        Theater_address = theaters.Theater_address,
                        Latitude = theaters.Latitude,
                        Longitude = theaters.Longitude
                    }).Distinct().ToList();

                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }

                    if (theaters_ == null)
                    {
                        return(NotFound());
                    }
                    return(Ok(theaters_));
                }
                else
                {
                    var theaters__ = (from theaters in db.Set <Theaters>()
                                      where theaters.Theater_name.Contains(theater_name)
                                      select new
                    {
                        Id_theater = theaters.Id_theater,
                        Theater_name = theaters.Theater_name,
                        Theater_site = theaters.Theater_site,
                        Theater_description = theaters.Theater_description,
                        Theater_address = theaters.Theater_address,
                        Latitude = theaters.Latitude,
                        Longitude = theaters.Longitude,
                    }).ToList();

                    if (!ModelState.IsValid)
                    {
                        return(BadRequest(ModelState));
                    }

                    if (theaters__ == null)
                    {
                        return(NotFound());
                    }
                    return(Ok(theaters__));
                }
            }
        }