Ejemplo n.º 1
0
 public async Task addMovie(SaveMoviesData saveMoviesData, string fileName)
 {
     List <SqlParameter> sqlParameters = new List <SqlParameter> {
         new SqlParameter {
             ParameterName = "@MovieName", Value = saveMoviesData.MovieName
         },
         new SqlParameter {
             ParameterName = "@YearOfRelease", Value = saveMoviesData.YearOfRelease
         },
         new SqlParameter {
             ParameterName = "@Plot", Value = saveMoviesData.Plot
         },
         new SqlParameter {
             ParameterName = "@PosterFileName", Value = fileName
         },
         new SqlParameter {
             ParameterName = "@ActorsCSV", Value = saveMoviesData.actorsCSV
         },
         new SqlParameter {
             ParameterName = "@ProducerID", Value = saveMoviesData.ProducerID
         }
     };
     //
     await _dXContext.Database.ExecuteSqlCommandAsync("usp_AddMovieDetails @MovieName,@YearOfRelease,@Plot,@PosterFileName,@ActorsCSV,@ProducerID", sqlParameters);
 }
Ejemplo n.º 2
0
        public async Task <bool> PostFormData([FromForm] SaveMoviesData data)
        {
            if (!data.IsNullOrDefault())
            {
                var    file     = data.poster;
                string fileName = data.MoviePoster;
                if (file != null && file.Length > 0)
                {
                    var ext = Path.GetExtension(file.FileName);
                    fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + "-" + file.Name + ext;
                    var path1 = @"E:\StudyArea\deltax-imdb\imdb\Presentation\DeltaX.Web\deltax-clientapp\src\assets\images\movies\";
                    var path2 = @"E:\StudyArea\deltax-imdb\imdb\Presentation\DeltaX.Web\dist\assets\images\movies\";


                    // copying to dev path
                    using (var stream = new FileStream(path1 + fileName, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);

                        await stream.FlushAsync();
                    }

                    // copying to prod path
                    using (var stream = new FileStream(path2 + fileName, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);

                        await stream.FlushAsync();
                    }
                }
                await _movieService.SaveMoviesData(data, fileName);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public async Task <bool> SaveMoviesData(SaveMoviesData saveMoviesData, string fileName)
        {
            if (saveMoviesData.MovieID != -1)
            {
                await _movieRepo.UpdateMovie(saveMoviesData, fileName);
            }
            else
            {
                await _movieRepo.addMovie(saveMoviesData, fileName);
            }

            return(false);
        }