Exemplo n.º 1
0
        public ClsUser GetUserByEmailId(string strEmailId)
        {
            ClsUser objClsUser = new ClsUser();

            try
            {
                using (objDataContext = GetDataContext())
                {
                    GetUserByEmailIdResult item = objDataContext.GetUserByEmailId(strEmailId).FirstOrDefault();
                    if (item != null)
                    {
                        objClsUser.LgId         = item.Id;
                        objClsUser.StrEmailID   = item.EmailID;
                        objClsUser.StrFirstName = item.FirstName;
                        objClsUser.StrSurName   = item.SurName;
                        objClsUser.StrMobileNo  = item.MobileNo;
                        objClsUser.StrPassword  = item.Password;
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
            }

            return(objClsUser);
        }
Exemplo n.º 2
0
        public ClsUser ChangePassword(long lgUserId, string strUserPwd)
        {
            ClsUser objUserMaster = new ClsUser(objDataContext);

            try
            {
                objUserMaster = GetUserByUserId(lgUserId);
                if (objUserMaster != null)
                {
                    objUserMaster.StrPassword = strUserPwd;
                }

                SaveUser(objUserMaster);
            }
            catch (Exception ex)
            {
                _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
            }

            return(objUserMaster);
        }
Exemplo n.º 3
0
        public ClsUser ValidateLogin(string strUserName, string strPassword)
        {
            try
            {
                using (objDataContext = GetDataContext())
                {
                    User objUser = objDataContext.Users.Where(n => n.UserName == strUserName && n.Password == strPassword && n.IsActive == true).FirstOrDefault();
                    if (objUser != null)
                    {
                        ClsUser objClsUser = new ClsUser
                        {
                            LgId            = objUser.Id,
                            LgBranchId      = objUser.BranchId,
                            LgUserTypeId    = objUser.UserTypeId,
                            StrFirstName    = objUser.FirstName,
                            StrSurName      = objUser.SurName,
                            StrMobileNo     = objUser.MobileNo,
                            StrEmailID      = objUser.EmailID,
                            StrUserName     = objUser.UserName,
                            StrPassword     = objUser.Password.DecryptString(),
                            StrAddress      = objUser.Address,
                            LgRoleId        = objUser.RoleId,
                            BlIsActive      = objUser.IsActive,
                            BlIsLogin       = objUser.IsLogin,
                            StrEmployeeCode = objUser.EmployeeCode
                        };
                        return(objClsUser);
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
                return(null);
            }
        }
Exemplo n.º 4
0
        public ClsUser GetUserByBranchAndUserType(long lgBranchId, long lgUserTypeId)
        {
            ClsUser objClsUser = new ClsUser(objDataContext);

            try
            {
                using (objDataContext = GetDataContext())
                {
                    var result = objDataContext.Users.Where(x => x.BranchId == lgBranchId && x.UserTypeId == lgUserTypeId);
                    if (result != null)
                    {
                        foreach (var item in result)
                        {
                            objClsUser.LgId            = item.Id;
                            objClsUser.StrFirstName    = item.FirstName;
                            objClsUser.StrSurName      = item.SurName;
                            objClsUser.StrMobileNo     = item.MobileNo;
                            objClsUser.StrEmailID      = item.EmailID;
                            objClsUser.StrUserName     = item.UserName;
                            objClsUser.StrPassword     = item.Password.DecryptString();
                            objClsUser.StrAddress      = item.Address;
                            objClsUser.LgRoleId        = item.RoleId;
                            objClsUser.LgBranchId      = item.BranchId;
                            objClsUser.LgUserTypeId    = item.UserTypeId;
                            objClsUser.BlIsActive      = item.IsActive;
                            objClsUser.BlIsLogin       = item.IsLogin;
                            objClsUser.StrEmployeeCode = item.EmployeeCode;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
            }

            return(objClsUser);
        }
Exemplo n.º 5
0
        public ClsUser GetUserByUserId(long lgUserId)
        {
            ClsUser objClsUser = new ClsUser();

            try
            {
                using (objDataContext = GetDataContext())
                {
                    GetUserByIdResult item = objDataContext.GetUserById(lgUserId).FirstOrDefault();
                    if (item != null)
                    {
                        objClsUser.LgId                  = item.Id;
                        objClsUser.StrFirstName          = item.FirstName;
                        objClsUser.StrSurName            = item.SurName;
                        objClsUser.StrMobileNo           = item.MobileNo;
                        objClsUser.StrEmailID            = item.EmailID;
                        objClsUser.StrUserName           = item.UserName;
                        objClsUser.StrPassword           = item.Password.DecryptString();
                        objClsUser.StrAddress            = item.Address;
                        objClsUser.LgRoleId              = item.RoleId;
                        objClsUser.LgBranchId            = item.BranchId;
                        objClsUser.StrBranchName         = item.UserBranchName;
                        objClsUser.LgUserTypeId          = item.UserTypeId;
                        objClsUser.BlIsActive            = item.IsActive;
                        objClsUser.BlIsLogin             = item.IsLogin;
                        objClsUser.StrEmployeeCode       = item.EmployeeCode;
                        objClsUser.LgVehicleDistributeId = item.VehicleDistributeId;
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
            }

            return(objClsUser);
        }
Exemplo n.º 6
0
 public long SaveUser(ClsUser objSave)
 {
     try
     {
         using (objDataContext = GetDataContext())
         {
             objSave.StrPassword = objSave.StrPassword.EncryptString();
             var result = objDataContext.InsertOrUpdateUser(objSave.LgId, 1, 1, objSave.StrFirstName, objSave.StrSurName, objSave.StrMobileNo, objSave.StrEmailID, objSave.StrUserName, objSave.StrPassword, objSave.StrAddress, "EMP/12345", objSave.LgRoleId, objSave.BlIsActive, objSave.BlIsLogin, _mySession.UserId, PageMaster.User).FirstOrDefault();
             if (result != null)
             {
                 return(result.InsertedId);
             }
             else
             {
                 return(0);
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
         return(0);
     }
 }