public async Task <IActionResult> Create(MediaCreateViewModel cvm) { Media newmedia = new Media() { Rating = cvm.Rating, CategoryId = cvm.CategoryId, Title = cvm.Title, Description = cvm.Description, Creator = cvm.Creator, Date = cvm.Date, PhotoUrl = cvm.PhotoUrl, Watched = cvm.Watched }; newmedia.Category = await _dbContext.Categories.FirstOrDefaultAsync(x => x.Id == newmedia.CategoryId); if (String.IsNullOrEmpty(newmedia.PhotoUrl)) { _photoService.AssignPicTomedia(newmedia); } _dbContext.Add(newmedia); await _dbContext.SaveChangesAsync(); return(RedirectToAction("Index")); }