public ActionResult Edit(Diet diet) { if (ModelState.IsValid) { diet.Foods.Clear(); diet.CattleTypes.Clear(); foreach (var idFood in diet.IdFoods) { diet.Foods.Add(_dairyFarmService.GetFoodById(idFood)); } foreach (var idCattleType in diet.IdCattleTypes) { diet.CattleTypes.Add(_dairyFarmService.GetCattleTypeById(idCattleType)); } diet.IdSeason = diet.IdSeason; diet.Label = diet.Label; var popup = new MessageInfo { State = 1, Message = "Regime bien édité" }; if (_dairyFarmService.EditDiet(diet) == false) { return(RedirectToAction("Index", "Diets", new { message = "Erreur dans l'édition", state = 0 })); } return(RedirectToAction("Index", "Diets", new { id = popup.Id, message = popup.Message, state = popup.State })); } return(RedirectToAction("Index", "Diets", new { message = "Erreur dans l'édition", state = 0 })); }