public IActionResult Create(MusicCreateViewModel model)
        {
            if (!TryValidateModel(model))
            {
                return(View(model));
            }
            var   currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);
            Music newMusic      = new Music()
            {
                Titel       = model.Titel,
                ZangersName = model.ZangersName,
                Lied        = model.Lied,
                MediaUser   = _currentMediaUser,
                MediaUserId = currentUserId
            };

            _mediaService.InsertMedia(newMusic);
            _mediaService.SaveChanges();

            Music muzFrmDb = _mediaService.GetAllMedia().OfType <Music>().FirstOrDefault(x => x.Id == newMusic.Id);

            if (model.Photo != null)
            {
                using var memoryStream = new MemoryStream();
                model.Photo.CopyTo(memoryStream);
                muzFrmDb.Photo = memoryStream.ToArray();
            }

            _mediaService.SaveChanges();

            return(RedirectToAction("Details", new { muzFrmDb.Id }));
        }
        public IActionResult Create(MovieCreateViewModel model)
        {
            if (!TryValidateModel(model))
            {
                return(View(model));
            }
            else
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();
            }
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);

            _currentMediaUser = _mediaService.GetAllMediaUsers().Where(u => u.Id == currentUserId).First();
            Movie newMovie = new Movie()
            {
                Titel       = model.Titel,
                Duration    = (model.Duration),
                IMDBLink    = model.IMDBLink,
                ReleaseDate = model.ReleaseDate,
                Status      = model.Status,
                MediaUser   = this._currentMediaUser,
                MediaUserId = currentUserId
            };

            _mediaService.InsertMedia(newMovie);
            _mediaService.SaveChanges();

            var foundMovie = _mediaService.GetAllMedia().OfType <Movie>().FirstOrDefault(x => x.Id == newMovie.Id);

            _mediaService.SaveChanges();

            if (model.Photo != null)
            {
                using var memoryStream = new MemoryStream();
                model.Photo.CopyTo(memoryStream);
                foundMovie.Photo = memoryStream.ToArray();
            }

            _mediaService.SaveChanges();

            return(RedirectToAction("Details", new { foundMovie.Id }));
        }