public bool AddPush(int? idSalon, List<string> prestationsId = null, ViewModelAddPush model = null) { try { if (model.IsNull() || prestationsId.IsEmpty() || idSalon.IsNull()) return false; if (model.Form.HeureDebut.IsNullOrEmpty() || model.Form.HeureDebut.Contains(':').IsFalse() || model.Form.HeureFin.IsNullOrEmpty() || model.Form.HeureFin.Contains(':').IsFalse()) return false; var salon = GetSalonById(idSalon); if (salon.IsNull()) return false; //On récup les type presta var listeTypePresta = prestationsId.Where(id => !id.IsNullOrEmpty()) .Select(id => TypePrestations.Find(id.ToInt())) .Where(typePrestation => !typePrestation.IsNull()).ToList(); if (listeTypePresta.IsEmpty()) return false; //Création du creneau var creneau = new Creneau(model.Form.HeureDebut, model.Form.HeureFin); var push = new Push { TypePrestations = listeTypePresta, NombreEmployes = model.Form.NombreEmployes, Pourcentage = model.Form.Pourcentage, Date = model.Form.Date, Creneau = creneau, IdSalon = (int)idSalon, }; Pushes.Add(push); SaveChanges(); return true; } catch (Exception) { return false; } }