public IActionResult OnPostOk() { if (ModelState.IsValid) { if (Excursion.ToursId == null) { Excursion.ToursId = new List <string>(); } _tourList.SynchronizeUpdating(Excursion); _excursionList.Update(Excursion); return(RedirectToPage("Excursions", new { userId = UserId })); } return(Page()); }
public static void SynchronizeAdding(this IExcursionCollection excursionList, Tour tour) { if (tour.AgenciesId == null) { return; } foreach (Excursion excursion in excursionList.Excursions) { Excursion newExcursion = excursion; if (tour.ExcursionsId.Contains(excursion.Id)) { newExcursion.ToursId.Add(tour.Id); excursionList.Update(newExcursion); } } }