public bool Authorize(string pStrUser, string pStrPassword, SpecialFunctionsEnum pEnmFunction) { var lObjUser = mObjUserDAO.GetEntitiesList() .Where(x => x.UserName == pStrUser) .Select(x => new { Id = x.Id, UserTypeId = x.UserTypeId, UserName = x.UserName, Password = x.Password }) .ToList() .Where(x => x.Password == pStrPassword.Encode()) .FirstOrDefault(); if (lObjUser != null) { return(mObjPermissionDAO.GetEntitiesList() .Where(x => x.AccessType == AccessTypeEnum.SPECIAL_FUNCTION && x.AccessId == (long)pEnmFunction && ( (x.PermissionType == PermissionTypeEnum.USER && x.PermissionId == lObjUser.Id) || (x.PermissionType == PermissionTypeEnum.USER_TYPE && x.PermissionId == lObjUser.UserTypeId) ) && x.AllowAccess ).Count() > 0); } else { throw new Exception("Usuario y/o contraseña inválido."); } }
public UCAuthorization(long pLonBatchId, SpecialFunctionsEnum pEnmFunction) { mLonBatchId = pLonBatchId; mEnmCurrentFunction = pEnmFunction; mObjSecurityFactory = new SecurityServicesFactory(); InitializeComponent(); }