public bool Insert(Staff obj, Dictionary <string, object> objAccount) { bool checkName = db.Staffs.Count(x => x.PSID == obj.PSID) > 0 ? true : false; //bool check = db.ApplicationUsers.Count(x => x.Username == user.Username) > 0 ? true : false; if (!checkName) { if (obj.PartnerID == -1) { obj.PartnerID = null; } db.Staffs.InsertOnSubmit(obj); if (objAccount != null) { var staffID = obj.ID; ApplicationUser user = new ApplicationUser(); user.Username = objAccount["Username"].ToString(); user.Password = HashText.GetSHA1HashData(objAccount["Password"].ToString()); user.Phone = obj.Phone; user.Status = 1; user.Locked = false; user.DateCreate = DateTime.Now; //user.StaffID = staffID; db.ApplicationUsers.InsertOnSubmit(user); } db.SubmitChanges(); return(true); } else { return(false); } }
public bool UpdatePassword(ApplicationUser user, string newPass) { bool checkUName = db.ApplicationUsers.Count(x => x.Username == user.Username && x.ID != user.ID) > 0 ? true : false; //bool check = db.ApplicationUsers.Count(x => x.Username == user.Username) > 0 ? true : false; if (!checkUName) { ApplicationUser currUser = db.ApplicationUsers.FirstOrDefault(x => x.ID == user.ID); if (currUser != null) { user.Password = HashText.GetSHA1HashData(newPass); currUser.LastUpdate = DateTime.Now; currUser.UpdateBy = Constant.CurrentSessionUser; db.SubmitChanges(); } return(true); } return(false); }
public bool Insert(ApplicationUser user) { bool checkUName = db.ApplicationUsers.Count(x => x.Username == user.Username) > 0 ? true : false; //bool check = db.ApplicationUsers.Count(x => x.Username == user.Username) > 0 ? true : false; if (!checkUName) { user.Password = HashText.GetSHA1HashData(user.Password); user.DateCreate = DateTime.Now; user.Status = 1; //Status: // 0: Bình thường // 1: Ngưng hoạt động db.ApplicationUsers.InsertOnSubmit(user); db.SubmitChanges(); return(true); } else { return(false); } }
public int CheckLogin(string username, string password) { string hashPass = HashText.GetSHA1HashData(password); ApplicationUser currUser = db.ApplicationUsers.FirstOrDefault(x => x.Username == username && x.Password == hashPass); if (currUser != null) { if (currUser.Locked == true) { return(2); } if (currUser.Status == 1) { return(1); } else { return(0); } } return(-1); }