public async Task <IActionResult> Create(SerieCreateViewModel model) { if (ModelState.IsValid) { Serie toBeAddedSerie = new Serie { Episode = model.Episode, ReleaseDate = model.ReleaseDate, Producer = model.Producer, Title = model.Title, Url = model.Url }; var user = await _userManager.GetUserAsync(HttpContext.User); _mediaDbContext.Series.Add(toBeAddedSerie); await _mediaDbContext.SaveChangesAsync(); UserSerie newConnection = new UserSerie { User = user, UserId = user.Id, Serie = toBeAddedSerie, SerieId = toBeAddedSerie.Id }; _mediaDbContext.UserSeries.Add(newConnection); await _mediaDbContext.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public void Insert(UserSerie userSerie) { contexto.Set <UserSerie>().Add(userSerie); contexto.SaveChanges(); }