public ActionResult PrzypiszPrzedmioty(PrzedmiotyGrupyViewModel model, string add, string remove, string send, int id) { ViewBag.Current = "Grupy"; // Aktualne zaznaczenie zakladki Profil w Menu //Need to clear model state or it will interfere with the updated model ModelState.Clear(); RestoreSavedState(model); if (!string.IsNullOrEmpty(add)) { AddProducts(model); } else if (!string.IsNullOrEmpty(remove)) { RemoveProducts(model); } else if (!string.IsNullOrEmpty(send)) { if (ModelState.IsValid) { var grupa = _repo.GetGroupByID(id); grupa.Przedmioty.Clear(); foreach (Przedmioty przedmiot in model.RequestedPrzedmioty) { grupa.Przedmioty.Add(przedmiot); } _repo.EditGroup(grupa); _repo.Save(); _logger.Info("GrupyController.Edit => SUCCES = Edit PRZYPISZPRZEMDIOTY| HTTP POST"); TempData["message"] = "Zauktalizowano grupę!"; TempData["status"] = "valid"; return(RedirectToAction("List")); } //todo: implement SendListToSanta method... } SaveState(model); return(View(model)); }