Example #1
0
 public static void RemoveMovie(MovieDTO m)
 {
     m.Removed = true;
     JobServiceDB.removeMovie(m);
 }
Example #2
0
 public void DeleteMovie(MovieDTO MovieId)
 {
     throw new NotImplementedException();
 }
Example #3
0
        public async Task GetMovieFromDB()
        {
            ApiHandler api = new ApiHandler(client);

            FetchedMovie = await api.GetSpecificMovieAsync(MovieId);
        }
Example #4
0
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string id = txtMovieID.Text.Trim();

            //check id null
            if (id.Equals(""))
            {
                SetMessageTextAndColor("MovieID cannot be null", Color.Red);
                return;
            }
            string title = txtMovieTitle.Text.Trim();

            if (title.Equals(""))
            {
                SetMessageTextAndColor("Movie Title cannot be null", Color.Red);
                return;
            }
            int   year = 0, length = 0;
            float rating = 0;

            try
            {
                length = Convert.ToInt32(txtLength.Text);
                if (length < 0)
                {
                    SetMessageTextAndColor("Movie length cannot be negative", Color.Red);
                    return;
                }
            }
            catch
            {
                SetMessageTextAndColor("Length must be a number", Color.Red);
            }
            try
            {
                year = Convert.ToInt32(txtYear.Text);
                if (year < 0)
                {
                    SetMessageTextAndColor("Year cannot be negative", Color.Red);
                    return;
                }
            }
            catch {
                SetMessageTextAndColor("Year must be a number", Color.Red);
            }
            try
            {
                rating = float.Parse(txtRating.Text);
                if (rating < 0)
                {
                    SetMessageTextAndColor("Rating cannot be negative", Color.Red);
                    return;
                }
            }
            catch
            {
                SetMessageTextAndColor("Rating must be a number", Color.Red);
            }
            string   producer  = txtProducer.Text.Trim();
            string   poster    = txtPoster.Text.Trim();
            string   trailer   = txtTrailer.Text.Trim();
            DateTime startDate = new DateTime();

            try
            {
                startDate = DateTime.Parse(txtStartDate.Text);
            }
            catch
            {
                SetMessageTextAndColor("Start Date is wrong format , format must be MM/dd/yyyy", Color.Red);
            }
            int genre = ReturnGenreID(dlGenre.SelectedValue);

            MovieDTO dto = new MovieDTO
            {
                MovieID     = id,
                MovieTitle  = title,
                Length      = length,
                Rating      = rating,
                StartDate   = startDate,
                Poster      = poster,
                LinkTrailer = trailer,
                Producer    = producer,
                Year        = year,
                Genre       = genre
            };

            try
            {
                if (MovieDao.AddNewMovie(dto))
                {
                    List <MovieDTO> list = (List <MovieDTO>)Session["MovieList"];
                    list.Add(dto);
                    gvStaffList.DataSource = list;
                    gvStaffList.DataBind();
                    SetMessageTextAndColor("Successfully added", Color.Green);
                    btnDelete.Enabled = true;
                    btnUpdate.Enabled = true;
                }
                else
                {
                    SetMessageTextAndColor("Failed to add", Color.Red);
                }
            }
            catch
            {
                SetMessageTextAndColor("Movie ID is already existed", Color.Red);
            }
        }
Example #5
0
 public IHttpActionResult Put(MovieDTO movie)
 {
     // Do some work (not shown).
     return(Content(HttpStatusCode.Accepted, movie));
 }
 /// <inheritdoc cref="IUpdatable{TDto}.UpdateAsync(TDto)"/>
 public async Task <MovieDTO> UpdateAsync(MovieDTO dto)
 {
     return(await _repository.UpdateAsync(dto));
 }
Example #7
0
        //Henter alt fra et tablenavn
        public List <object> GetAll(string TableName, string ColumnToCheckName = null, string ValueToMatch = null, Type Type = null)
        {
            List <object> LisReturn    = new List <object>();
            string        FilterString = string.Empty;

            if (ColumnToCheckName != null && ValueToMatch != null && Type != null)
            {
                if (Type == typeof(decimal))
                {
                    FilterString = (" WHERE " + ColumnToCheckName + " = " + ValueToMatch.Replace(",", "."));
                }
                else if (Type == typeof(string))
                {
                    FilterString = (" WHERE " + ColumnToCheckName + " = '" + ValueToMatch + "'");
                }
                else if (Type == typeof(bool))
                {
                    FilterString = (" WHERE " + ColumnToCheckName + " = " + (Convert.ToBoolean(ValueToMatch) ? 1 : 0));
                }
                else if (Type == typeof(DateTime))
                {
                    FilterString = (" WHERE " + ColumnToCheckName + " = '" + Convert.ToDateTime(ValueToMatch).ToString("yyyy-MM-dd HH:mm:ss.fffffff") + "'");
                }
                else if (Type == typeof(int))
                {
                    FilterString = (" WHERE " + ColumnToCheckName + " = " + ValueToMatch);
                }
            }
            try
            {
                using (SqlConnection Con = new SqlConnection(ConfigConnectionString))
                {
                    Con.Open();
                    string CommandString = "SELECT * FROM " + TableName + FilterString;
                    using (SqlCommand Com = new SqlCommand(CommandString, Con))
                    {
                        using (SqlDataReader reader = Com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                bool   Skip      = false;
                                object ObjReturn = new object();
                                switch (TableName)
                                {
                                case "Movie":
                                    MovieDTO Movie = new MovieDTO();
                                    ObjReturn = Movie;
                                    break;

                                case "Reservation":
                                    ReservationDTO Reservation = new ReservationDTO();
                                    ObjReturn = Reservation;
                                    break;

                                case "Resource":
                                    ResourceDTO Resource = new ResourceDTO();
                                    ObjReturn = Resource;
                                    break;

                                case "Screening":
                                    ScreeningDTO Screening = new ScreeningDTO();
                                    ObjReturn = Screening;
                                    break;

                                case "Seat":
                                    SeatDTO Seat = new SeatDTO();
                                    ObjReturn = Seat;
                                    break;

                                case "Theater":
                                    TheaterDTO Theater = new TheaterDTO();
                                    ObjReturn = Theater;
                                    break;

                                case "MovieScreening":
                                    MovieScreeningDTO MovieScreening = new MovieScreeningDTO();
                                    ObjReturn = MovieScreening;
                                    break;

                                case "ResourceScreening":
                                    ResourceScreeningDTO ResourceScreening = new ResourceScreeningDTO();
                                    ObjReturn = ResourceScreening;
                                    break;

                                default:
                                    ObjReturn = null;
                                    Skip      = true;
                                    break;
                                }
                                if (!Skip)
                                {
                                    //Løber igennem properties og sætter property til værdien den finder i rækkens felt med samme kolonnenavn som propertyname
                                    foreach (PropertyInfo pi in ObjReturn.GetType().GetProperties())
                                    {
                                        pi.SetValue(ObjReturn, reader.GetValue(reader.GetOrdinal(pi.Name)));
                                    }
                                    LisReturn.Add(ObjReturn);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                LisReturn.Add(Ex);
            }
            return(LisReturn);
        }
Example #8
0
 //DTO?
 public void CreateMovie(MovieDTO movieDTO)
 {
     movieCollectionDAL.CreateMovie(movieDTO);
 }
Example #9
0
 public void UpdateMovie(MovieDTO movieDTO)
 {
     movieDAL.Update(movieDTO, movieDTO.ID);
 }
Example #10
0
 public static void quitMovie(ActorDTO actorDTO, MovieDTO movieDTO)
 {
     JobServiceDB.getMovieById(movieDTO.Id).Job.assigned = false;
     JobServiceDB.getMovieById(movieDTO.Id).idActor      = null;
     JobServiceDB.DBaccess.SaveChanges();
 }
 public void SaveMovie([FromBody] MovieDTO movie, Guid movieId)
 {
     _movieManagement.AddOrUpdate(movie);
 }
 public void Post([FromBody] MovieDTO dto, [FromServices] ICreateMovieCommand command)
 {
     executor.ExecuteCommand(command, dto);
 }
Example #13
0
 // Check if movie exist in database
 public bool movieExist(MovieDTO mdt)
 {
     return(_DB.Movies.Any(m => m.title == mdt.Title));
 }
Example #14
0
 public static void AssignMovie(MovieDTO m, ActorDTO a)
 {
     m.Assigned = true;
     a.MovieList.Add(m);
     JobServiceDB.assignMovie(m, a);
 }
        /// <summary>
        /// Use this method for your mainlinks. Eg CRUD, just add
        /// more links to your CRUD methods inside
        /// Wollter
        /// </summary>
        /// <param name="movie"></param>
        /// <returns></returns>
        internal MovieDTO HateoasGetAllMethodLinks(MovieDTO movieDto)
        {
            movieDto.Links.Add(UrlLink("_self", "GetIdAsync", new { id = movieDto.MovieID }));

            return(movieDto);
        }
Example #16
0
        public async Task <MovieDTO> PutMovie(int id, MovieDTO movieDTO)
        {
            if (movieDTO == null)
            {
                throw new ArgumentNullException(nameof(movieDTO));
            }

            try
            {
                Movie movie = await _context.Movies.Include(s => s.MovieActors)
                              .Include(s => s.MovieGenres).FirstOrDefaultAsync(s => s.Id == id).ConfigureAwait(false);

                movie.Name     = movieDTO.Name;
                movie.Synopsis = movieDTO.Synopsis;
                movie.Director = movieDTO.Director;
                movie.Aired    = movieDTO.Aired;
                movie.Duration = movieDTO.Duration;
                movie.Score    = movieDTO.Score;
                movie.Image    = movieDTO.Image;

                _context.MovieActors.RemoveRange(movie.MovieActors);

                foreach (MovieActorDTO movieActorDTO in movieDTO.MovieActorDTOs)
                {
                    Actor actor = _context.Actors.Find(movieActorDTO.ActorId);
                    movie.MovieActors.Add(new MovieActor()
                    {
                        MovieId = movie.Id,
                        Movie   = movie,
                        ActorId = actor.Id,
                        Actor   = actor
                    });
                }

                _context.MovieGenres.RemoveRange(movie.MovieGenres);

                foreach (MovieGenreDTO movieGenreDTO in movieDTO.MovieGenreDTOs)
                {
                    Genre genre = _context.Genres.Find(movieGenreDTO.GenreId);
                    movie.MovieGenres.Add(new MovieGenre()
                    {
                        MovieId = movie.Id,
                        Movie   = movie,
                        GenreId = genre.Id,
                        Genre   = genre
                    });
                }

                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MovieExists(id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(movieDTO);
        }
Example #17
0
 public void Execute(MovieDTO request)
 {
     throw new NotImplementedException();
 }
 public IActionResult Add(MovieDTO model, string name, string descreption, string categoryName)
 {
     movieService.Add(model, name, descreption, categoryName);
     return(new JsonResult(""));
 }
Example #19
0
        //Henter en række fra et tablenavn hvor id findes
        public object Get(string TableName, int Id)
        {
            object ObjReturn = new object();

            switch (TableName)
            {
            case "Movie":
                MovieDTO Movie = new MovieDTO();
                ObjReturn = Movie;
                break;

            case "Reservation":
                ReservationDTO Reservation = new ReservationDTO();
                ObjReturn = Reservation;
                break;

            case "Resource":
                ResourceDTO Resource = new ResourceDTO();
                ObjReturn = Resource;
                break;

            case "Screening":
                ScreeningDTO Screening = new ScreeningDTO();
                ObjReturn = Screening;
                break;

            case "Seat":
                SeatDTO Seat = new SeatDTO();
                ObjReturn = Seat;
                break;

            case "Theater":
                TheaterDTO Theater = new TheaterDTO();
                ObjReturn = Theater;
                break;

            case "MovieScreening":
                MovieScreeningDTO MovieScreening = new MovieScreeningDTO();
                ObjReturn = MovieScreening;
                break;

            default:
                ObjReturn = null;
                break;
            }
            if (ObjReturn != null)
            {
                try
                {
                    using (SqlConnection con = new SqlConnection(ConfigConnectionString))
                    {
                        con.Open();
                        using (SqlCommand com = new SqlCommand("SELECT * FROM " + TableName + " where id = " + Id.ToString(), con))
                        {
                            using (SqlDataReader reader = com.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    //Løber igennem properties og sætter property til værdien den finder i rækkens felt med samme kolonnenavn som propertyname
                                    foreach (PropertyInfo pi in ObjReturn.GetType().GetProperties())
                                    {
                                        pi.SetValue(ObjReturn, reader.GetValue(reader.GetOrdinal(pi.Name)));
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {
                    return(Ex);
                }
            }
            return(ObjReturn);
        }
 public IActionResult Edit(MovieDTO model, int Id, string name, string descreption, string categoryName, string[] IdToAdd)
 {
     movieService.Update(model, Id, name, descreption, categoryName, IdToAdd);
     return(new JsonResult(""));
 }
Example #21
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string id = txtMovieID.Text.Trim();

            //check id null
            if (id.Equals(""))
            {
                SetMessageTextAndColor("MovieID cannot be null", Color.Red);
                return;
            }
            string title = txtMovieTitle.Text.Trim();

            if (title.Equals(""))
            {
                SetMessageTextAndColor("Movie Title cannot be null", Color.Red);
                return;
            }
            int   year = 0, length = 0;
            float rating = 0;

            try
            {
                length = Convert.ToInt32(txtLength.Text);
                if (length < 0)
                {
                    SetMessageTextAndColor("Movie length cannot be negative", Color.Red);
                    return;
                }
            }
            catch
            {
                SetMessageTextAndColor("Length must be a number", Color.Red);
            }
            try
            {
                year = Convert.ToInt32(txtYear.Text);
                if (year < 0)
                {
                    SetMessageTextAndColor("Year cannot be negative", Color.Red);
                    return;
                }
            }
            catch
            {
                SetMessageTextAndColor("Year must be a number", Color.Red);
            }
            try
            {
                rating = float.Parse(txtRating.Text);
                if (rating < 0)
                {
                    SetMessageTextAndColor("Rating cannot be negative", Color.Red);
                    return;
                }
            }
            catch
            {
                SetMessageTextAndColor("Rating must be a number", Color.Red);
            }
            string   producer  = txtProducer.Text.Trim();
            string   poster    = txtPoster.Text.Trim();
            string   trailer   = txtTrailer.Text.Trim();
            DateTime startDate = new DateTime();

            try
            {
                startDate = DateTime.Parse(txtStartDate.Text);
            }
            catch
            {
                SetMessageTextAndColor("Start Date is wrong format , format must be MM/dd/yyyy", Color.Red);
            }
            int genre = ReturnGenreID(dlGenre.SelectedValue);

            MovieDTO dto = new MovieDTO
            {
                MovieID     = id,
                MovieTitle  = title,
                Length      = length,
                Rating      = rating,
                StartDate   = startDate,
                Poster      = poster,
                LinkTrailer = trailer,
                Producer    = producer,
                Year        = year,
                Genre       = genre
            };

            try
            {
                if (MovieDao.UpdateMovie(dto))
                {
                    List <MovieDTO> list = (List <MovieDTO>)Session["AdminMovieSearch"];
                    foreach (MovieDTO item in list)
                    {
                        if (item.MovieID.Equals(id))
                        {
                            item.MovieTitle  = dto.MovieTitle;
                            item.Year        = dto.Year;
                            item.Length      = dto.Length;
                            item.Rating      = dto.Rating;
                            item.Producer    = dto.Producer;
                            item.Poster      = dto.Poster;
                            item.LinkTrailer = dto.LinkTrailer;
                            item.StartDate   = dto.StartDate;
                            item.Genre       = dto.Genre;
                        }
                    }
                    gvStaffList.DataSource = list;
                    gvStaffList.DataBind();
                    SetMessageTextAndColor("Successfully updated", Color.Green);
                }
                else
                {
                    SetMessageTextAndColor("Failed to update", Color.Red);
                }
            }
            catch
            {
                SetMessageTextAndColor("Server encounter a fatal error please try again later.", Color.Red);
            }
        }
Example #22
0
 public void AddMovie(MovieDTO movie)
 {
     Add <Movie>(mapper.Map <Movie>(movie));
     Save();
 }
        public IActionResult GetMovieById(int id)
        {
            MovieDTO objectList = _moviesService.GetMovieById(id);

            return(Ok(objectList));
        }
Example #24
0
 public void EditMovie(MovieDTO movie)
 {
     Edit <Movie>(mapper.Map <Movie>(movie));
     Save();
 }
        /// <summary>
        /// Adds the provided Movie and all associated information (Actors, Directors, Genres,
        /// Languages, Tags) to the provided context. Assumes the all Movie information is
        /// unique, GetRandomMovie() provides a Movie with information that is astronomically
        /// unlikely to repeat.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="movieDTO"></param>
        public static void AddMovieDTOToDatabase(Cinephiliacs_MovieContext context, MovieDTO movieDTO)
        {
            Movie movie = new Movie();

            movie.ImdbId = movieDTO.ImdbId;
            movie.Title  = movieDTO.Title;

            Rating newRating = new Rating();

            newRating.RatingName = movieDTO.RatingName;
            context.Ratings.Add(newRating);
            context.SaveChanges();
            movie.RatingId = context.Ratings.FirstOrDefault(r => r.RatingName == movieDTO.RatingName).RatingId;

            movie.ReleaseDate    = DateTime.ParseExact(movieDTO.ReleaseDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
            movie.IsReleased     = true;
            movie.ReleaseCountry = movieDTO.ReleaseCountry;
            movie.RuntimeMinutes = movieDTO.RuntimeMinutes;
            movie.Plot           = movieDTO.Plot;
            movie.PosterUrl      = movieDTO.PosterURL;

            context.Movies.Add(movie);
            context.SaveChanges();

            foreach (var movieActorName in movieDTO.MovieActors)
            {
                Actor newActor = new Actor();
                newActor.ActorName = movieActorName;
                context.Actors.Add(newActor);
                context.SaveChanges();

                Actor actor = context.Actors.FirstOrDefault(a => a.ActorName == movieActorName);

                MovieActor movieActor = new MovieActor();
                movieActor.ImdbId  = movieDTO.ImdbId;
                movieActor.ActorId = actor.ActorId;
                context.MovieActors.Add(movieActor);
                context.SaveChanges();
            }

            foreach (var movieDirectorName in movieDTO.MovieDirectors)
            {
                Director newDirector = new Director();
                newDirector.DirectorName = movieDirectorName;
                context.Directors.Add(newDirector);
                context.SaveChanges();

                Director director = context.Directors.FirstOrDefault(d => d.DirectorName == movieDirectorName);

                MovieDirector movieDirector = new MovieDirector();
                movieDirector.ImdbId     = movieDTO.ImdbId;
                movieDirector.DirectorId = director.DirectorId;
                context.MovieDirectors.Add(movieDirector);
                context.SaveChanges();
            }

            foreach (var movieGenreName in movieDTO.MovieGenres)
            {
                Genre newGenre = new Genre();
                newGenre.GenreName = movieGenreName;
                context.Genres.Add(newGenre);
                context.SaveChanges();

                Genre genre = context.Genres.FirstOrDefault(a => a.GenreName == movieGenreName);

                MovieGenre movieGenre = new MovieGenre();
                movieGenre.ImdbId  = movieDTO.ImdbId;
                movieGenre.GenreId = genre.GenreId;
                context.MovieGenres.Add(movieGenre);
                context.SaveChanges();
            }

            foreach (var movieLanguageName in movieDTO.MovieLanguages)
            {
                Language newLanguage = new Language();
                newLanguage.LanguageName = movieLanguageName;
                context.Languages.Add(newLanguage);
                context.SaveChanges();

                Language language = context.Languages.FirstOrDefault(a => a.LanguageName == movieLanguageName);

                MovieLanguage movieLanguage = new MovieLanguage();
                movieLanguage.ImdbId     = movieDTO.ImdbId;
                movieLanguage.LanguageId = language.LanguageId;
                context.MovieLanguages.Add(movieLanguage);
                context.SaveChanges();
            }

            foreach (var movieTagName in movieDTO.MovieTags)
            {
                Tag newTag = new Tag();
                newTag.TagName  = movieTagName;
                newTag.IsBanned = false;
                context.Tags.Add(newTag);
                context.SaveChanges();

                MovieTag movieTag = new MovieTag();
                movieTag.ImdbId  = movieDTO.ImdbId;
                movieTag.TagName = movieTagName;
                movieTag.VoteSum = 1;
                context.MovieTags.Add(movieTag);
                context.SaveChanges();
            }
        }
Example #26
0
 public static void QuitMovie(ActorDTO a, MovieDTO m)
 {
     m.Assigned = false;
     a.MovieList.Remove(a.MovieList.FirstOrDefault(x => x.Id == m.Id));
     UserServiceDB.quitMovie(a, m);
 }
Example #27
0
 public void EditMovie(MovieDTO dto)
 {
     throw new NotImplementedException();
 }
Example #28
0
        public void Put(int id, MovieDTO value)
        {
            Movie model = IMovieRepository.Get(id);

            if (value.Title != null)
            {
                model.Title = value.Title;
            }
            if (value.ReleaseDate != null)
            {
                model.ReleaseDate = value.ReleaseDate;
            }
            if (value.RunTime != 0)
            {
                model.RunTime = value.RunTime;
            }
            if (value.Vote != 0)
            {
                model.Vote = value.Vote;
            }
            IMovieRepository.Update(model);

            if (value.ActorId != null)
            {
                IEnumerable <MovieActor> MyMovieActors = IMovieActorRepository.GetAll().Where(x => x.MovieId == id);
                foreach (MovieActor MyMovieActor in MyMovieActors)
                {
                    IMovieActorRepository.Delete(MyMovieActor);
                }
                for (int i = 0; i < value.ActorId.Count; i++)
                {
                    MovieActor MovieActor = new MovieActor()
                    {
                        MovieId = model.Id,
                        ActorId = value.ActorId[i]
                    };
                    IMovieActorRepository.Create(MovieActor);
                }
            }
            if (value.CompanyId != null)
            {
                IEnumerable <MovieCompany> MyMovieCompanies = IMovieCompanyRepository.GetAll().Where(x => x.MovieId == id);
                foreach (MovieCompany MyMovieCompany in MyMovieCompanies)
                {
                    IMovieCompanyRepository.Delete(MyMovieCompany);
                }
                for (int i = 0; i < value.CompanyId.Count; i++)
                {
                    MovieCompany MovieCompany = new MovieCompany()
                    {
                        MovieId   = model.Id,
                        CompanyId = value.CompanyId[i]
                    };
                    IMovieCompanyRepository.Create(MovieCompany);
                }
            }
            if (value.GenreId != null)
            {
                IEnumerable <MovieGenre> MyMovieGenres = IMovieGenreRepository.GetAll().Where(x => x.MovieId == id);
                foreach (MovieGenre MyMovieGenre in MyMovieGenres)
                {
                    IMovieGenreRepository.Delete(MyMovieGenre);
                }
                for (int i = 0; i < value.GenreId.Count; i++)
                {
                    MovieGenre MovieGenre = new MovieGenre()
                    {
                        MovieId = model.Id,
                        GenreId = value.GenreId[i]
                    };
                    IMovieGenreRepository.Create(MovieGenre);
                }
            }
        }
Example #29
0
 public ActionResult Create([Bind(Include = "MovieID,Name,SmallPictureUrl,LargePictureUrl,HasReleased,LanguageID")] MovieDTO movie)
 {
     throw new NotImplementedException();
 }
Example #30
0
 public static void EditMovie(MovieDTO m)
 {
     JobServiceDB.editMovie(m);
 }