Ejemplo n.º 1
0
 public async Task <IActionResult> CreateMovie(CreateMovieRequest request)
 {
     if (ModelState.IsValid)
     {
         string url = "";
         if (request.File == null)
         {
             url = "https://localhost:44304/img/movie.jpg";
         }
         else
         {
             url = await ImageHandler.UploadImage(request.File);
         }
         var movie = new Movie
         {
             DateUpload  = DateTime.Now,
             Description = request.Description,
             Director    = request.Director,
             URL         = url,
             Name        = request.Name,
             MovieTypeId = request.MovieTypeId,
             MovieId     = Guid.NewGuid().ToString()
         };
         AdministrationRepository.AddMovie(movie);
         return(RedirectToAction("GetMovies"));
     }
     foreach (var error in ModelState.Values)
     {
         foreach (var item in error.Errors)
         {
             Logger.LogError(item.ErrorMessage);
         }
     }
     return(View("GetMovies"));
 }