public static bool UpdateUserInfo(Com.User mUser) { try { using (var ent = DB.Entity) { ent.Users.Attach(mUser); var Entry = ent.Entry(mUser); Entry.Property(ex => ex.CodeMeli).IsModified = true; Entry.Property(ex => ex.Email).IsModified = true; Entry.Property(ex => ex.FamilyName).IsModified = true; Entry.Property(ex => ex.NickName).IsModified = true; Entry.Property(ex => ex.Name).IsModified = true; Entry.Property(ex => ex.Address).IsModified = true; Entry.Property(ex => ex.CodePosti).IsModified = true; Entry.Property(ex => ex.City).IsModified = true; Entry.Property(ex => ex.Ostan).IsModified = true; ent.SaveChanges(); return(true); } } catch (Exception e) { new System.Threading.Thread(delegate() { Log.DoLog(Com.Common.Action.UpdateUserInfo, mUser.UID.ToString(), -100, e.Message); }); return(false); } }
public static bool UpdateUserAfterLogin(Com.User mUser) { try { using (var ent = DB.Entity) { ent.Users.Attach(mUser); var Entry = ent.Entry(mUser); Entry.Property(ex => ex.Active).IsModified = true; Entry.Property(ex => ex.NickName).IsModified = true; Entry.Property(ex => ex.DeviceID).IsModified = true; Entry.Property(ex => ex.FBToken).IsModified = true; ent.SaveChanges(); return(true); } } catch (Exception e) { new System.Threading.Thread(delegate() { Log.DoLog(Com.Common.Action.UpdateUserAfterLogin, mUser.UID.ToString(), -100, e.Message); }); return(false); } }
public Com.LogonResult Logon(string TellNumber) { try { Com.User mUser = BLL.User.GetUserByTellNumber(TellNumber); if (mUser == null) { mUser = new Com.User() { TellNumber = TellNumber, LastLogin = DateTime.Now, Active = false, Credit = 500, JoinDate = DateTime.Now, RewardState = 0, ActiveCode = "12345"// CreateRandomCode() }; mUser.UID = BLL.User.AddUser(mUser); if (mUser.UID < 0) { return(new Com.LogonResult() { IsNew = true, HasError = true, NickName = "", UserID = mUser.UID }); } else { // new System.Threading.Thread(delegate () { SendActivationCodeViaSMS(TellNumber, mUser.ActiveCode); }).Start(); return(new Com.LogonResult() { IsNew = true, HasError = false, NickName = "", UserID = mUser.UID }); } } else { string NewActiveCode = "123456"; // CreateRandomCode(); if (TellNumber == "989123456789") //mehr { NewActiveCode = "12345"; } mUser.ActiveCode = NewActiveCode; bool Res = BLL.User.UpdateUserCode(mUser); //new System.Threading.Thread(delegate () { SendActivationCodeViaSMS(TellNumber, NewActiveCode); }).Start(); return(new Com.LogonResult() { IsNew = false, HasError = false, NickName = mUser.NickName, UserID = mUser.UID }); } } catch (Exception e) { new System.Threading.Thread(delegate() { BLL.Log.DoLog(Com.Common.Action.Logon, TellNumber, -200, e.Message); }).Start(); return(new Com.LogonResult() { IsNew = false, HasError = true, NickName = e.Message, UserID = 0 }); } }
public static int AddUser(Com.User mUser) { try { using (var ent = DB.Entity) { ent.Users.Add(mUser); ent.SaveChanges(); return(mUser.UID); } } catch (Exception e) { new System.Threading.Thread(delegate() { Log.DoLog(Com.Common.Action.AddUser, mUser.TellNumber, -100, e.Message); }); return(-100); } }