public async Task AddCartItem(int customerId, CartViewModel vm) { var item = await CartItems.Include(i => i.Movie).FirstOrDefaultAsync(i => i.Movie.Id == vm.MovieId); var movie = await MovieInfos.FirstOrDefaultAsync(i => i.Id == vm.MovieId); if (item == null && movie != null) { await CartItems.AddAsync(new CartItem { CustomerId = customerId, Movie = movie, Paid = false, Price = vm.Price, ProvidedBy = vm.ProvidedBy }); await SaveChangesAsync(); } }