/// <summary>
        /// Metoda care updateaza facilitatile unei unitati.
        /// </summary>
        /// <param name="idUnitate">id-ul unitatii careia vrem sa ii updatam facilitatile</param>
        /// <param name="newFacilitatiIds">id-urile facilitatilor pe care vrem sa le adaugam</param>
        public static void EditFacilitatiforUnitate(int idUnitate, List<int> newFacilitatiIds)
        {
            try
            {
                using (MasterEntities context = new MasterEntities())
                {
                    var user = context.Unitati.Include("Facilitatis").Single(u => u.idUnitate == idUnitate);

                    foreach (var fac in user.Facilitatis.ToList())
                    {
                        // sterge rolurile care nu sunt in noua lista
                        if (!newFacilitatiIds.Contains(fac.idFacilitate))
                            user.Facilitatis.Remove(fac);
                    }

                    foreach (var newFacilitateId in newFacilitatiIds)
                    {
                        // adauga rolurile care nu sunt in lista de roluri a userului
                        if (!user.Facilitatis.Any(r => r.idFacilitate == newFacilitateId))
                        {
                            var newFacilitate = new Facilitati { idFacilitate = newFacilitateId };
                            context.Facilitati.Attach(newFacilitate);
                            user.Facilitatis.Add(newFacilitate);
                        }
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex) { }
        }
 /// <summary>
 /// Create a new Facilitati object.
 /// </summary>
 /// <param name="idFacilitate">Initial value of the idFacilitate property.</param>
 /// <param name="numeFacilitate">Initial value of the numeFacilitate property.</param>
 public static Facilitati CreateFacilitati(global::System.Int32 idFacilitate, global::System.String numeFacilitate)
 {
     Facilitati facilitati = new Facilitati();
     facilitati.idFacilitate = idFacilitate;
     facilitati.numeFacilitate = numeFacilitate;
     return facilitati;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Facilitati EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFacilitati(Facilitati facilitati)
 {
     base.AddObject("Facilitati", facilitati);
 }