コード例 #1
0
 /// <summary>
 /// Metoda care sterge un utilizator.
 /// </summary>
 /// <param name="utilizator">utilizatorul pe care dorim sa il stergem</param>
 public static void DeleteUtilizator(Utilizatori utilizator)
 {
     try
     {
         using (MasterEntities context = new MasterEntities())
         {
             var obj = context.Utilizatori.First(x => x.idUtilizator == utilizator.idUtilizator);
             obj.isDeleted = true;
             context.ApplyCurrentValues("Utilizatori", obj);
             context.SaveChanges();
         }
     }
     catch (Exception exc) { throw exc; }
 }
コード例 #2
0
        /// <summary>
        /// Metoda care creeaza un nou user atunci cand acesta se inregistreaza.
        /// </summary>
        /// <param name="numeUtilizator">username-ul completat din formularul de inregistrare </param>
        /// <param name="parola">parola completata in formularul de inregistrare</param>
        /// <param name="email">emailul completat in formularul de inregistrare</param>
        /// <param name="numeComplet">numele complet al utilizatorului completat in formularul de inregistrare</param>
        /// <param name="passwordAnswer"></param>
        /// <param name="isApproved"></param>
        /// <param name="providerUserKey"></param>
        /// <param name="status">statusul crearii userului: e.g:Success daca crearea s-a efectuat cu succes</param>
        /// <returns></returns>
        public override MembershipUser CreateUser(string numeUtilizator, string parola, string email, string numeComplet, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            MembershipUser myUser=null;
            string encryptedPass = encryptUserPassword(parola);
            using (MasterEntities context = new MasterEntities())
            {
                Utilizatori user = new Utilizatori();
                user.numeUtilizator = numeUtilizator;
                user.numeComplet = numeComplet;
                user.email = email;
                user.parola = encryptedPass;
                user.isDeleted = false;

                context.Utilizatori.AddObject(user);
                context.SaveChanges();

                myUser = new MembershipUser("MyCustomMembership", user.numeUtilizator, user.idUtilizator, user.email, user.numeUtilizator, string.Empty,
                                              true, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue);
                //isLockedOut = isDeleted = false cand cream prima data un user
                status = MembershipCreateStatus.Success;
            }

            return myUser;
        }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Utilizatori EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUtilizatori(Utilizatori utilizatori)
 {
     base.AddObject("Utilizatori", utilizatori);
 }
コード例 #4
0
 /// <summary>
 /// Create a new Utilizatori object.
 /// </summary>
 /// <param name="idUtilizator">Initial value of the idUtilizator property.</param>
 /// <param name="numeUtilizator">Initial value of the numeUtilizator property.</param>
 /// <param name="email">Initial value of the email property.</param>
 /// <param name="parola">Initial value of the parola property.</param>
 /// <param name="numeComplet">Initial value of the numeComplet property.</param>
 public static Utilizatori CreateUtilizatori(global::System.Int32 idUtilizator, global::System.String numeUtilizator, global::System.String email, global::System.String parola, global::System.String numeComplet)
 {
     Utilizatori utilizatori = new Utilizatori();
     utilizatori.idUtilizator = idUtilizator;
     utilizatori.numeUtilizator = numeUtilizator;
     utilizatori.email = email;
     utilizatori.parola = parola;
     utilizatori.numeComplet = numeComplet;
     return utilizatori;
 }
コード例 #5
0
 /// <summary>
 /// Metoda care updateaza datele unui utilizator.
 /// </summary>
 /// <param name="utilizator">noile date ale utilizatorului</param>
 /// <param name="origUtilizator">utilizatorul pe care dorim sa il updatam</param>
 public static void UpdateUtilizator(Utilizatori utilizator, Utilizatori origUtilizator)
 {
     try
     {
         using (MasterEntities context = new MasterEntities())
         {
             context.Utilizatori.Attach(origUtilizator);
             context.ApplyCurrentValues("Utilizatori", utilizator);
             context.SaveChanges();
         }
     }
     catch (Exception exc) { throw exc; }
 }