示例#1
0
        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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
        }