public ActionResult AddMovie(MovieViewModel movieViewModel)
 {
     movieViewModel.Id = Guid.NewGuid();
     ctx.Movies.Add(new Movie(movieViewModel));
     ctx.SaveChanges();
     return RedirectToAction("Index", "Home");
 }
Exemple #2
0
        public Movie(MovieViewModel movieViewModel)
        {
            Id = movieViewModel.Id;
            HebrewTitle = movieViewModel.HebrewTitle;
            EnglishTitle = movieViewModel.EnglishTitle;
            Category = movieViewModel.Category;
            Summery = movieViewModel.Summery;
            Rank = movieViewModel.Rank;
            ReleaseDate = movieViewModel.ReleaseDate;
            Length = movieViewModel.Length;
            Directors = movieViewModel.Directors;
            Producers = movieViewModel.Producers;
            Actors = movieViewModel.Actors;

            if (movieViewModel.Image.ContentLength > 0)
            {
                byte[] fileBytes = new byte[movieViewModel.Image.InputStream.Length];
                int byteCount = movieViewModel.Image.InputStream.Read(fileBytes, 0, (int)movieViewModel.Image.InputStream.Length);
                Image = Convert.ToBase64String(fileBytes);
            }
        }