示例#1
0
 public bool Update(user a)
 {
     try
     {
         using (var ctx = new AuthContext())
         {
             if (ctx.users.Any(el => el.login == a.login)) { return false; }
             ctx.AddTousers(a);
             ctx.ObjectStateManager.ChangeObjectState(a, EntityState.Modified);
             ctx.SaveChanges();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
示例#2
0
 public bool Register(string login , string password)
 {
     try
     {
         using (var ctx = new AuthContext())
         {
             if (ctx.users.Any(el => el.login == login)) return false;
             var u = new user() { login = login, password = password };
             ctx.AddTousers(u);
             ctx.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTousers(user user)
 {
     base.AddObject("users", user);
 }
 /// <summary>
 /// Create a new user object.
 /// </summary>
 /// <param name="user_id">Initial value of the user_id property.</param>
 public static user Createuser(global::System.Int64 user_id)
 {
     user user = new user();
     user.user_id = user_id;
     return user;
 }