Beispiel #1
0
        public static Agent ToDTOModel(this DataAccess.Agent item)
        {
            if (item == null)
            {
                return(null);
            }

            return(new Agent
            {
                UUID = item.UUID,
                FirstName = item.FirstName,
                LastName = item.LastName
            });
        }
Beispiel #2
0
        private static bool IsTransactionAutheticated(dynamic AgentObj)
        {
            dynamic            agObj = new DataAccess.Agent();
            HttpRequestMessage req   = new HttpRequestMessage();

            try
            {
                var    agentID   = AgentObj.AgentID;
                var    agentKey  = AgentObj.AgentKey;
                string signature = AgentObj.Signature;
                string agtKey    = agentKey;
                string agtID     = agentID;

                WebLog.Log("agentID:" + agentID + " agentKey:" + agentKey + " signature:" + signature);
                //get details from database.

                DataAccess.GlobalTransactEntitiesData globallending = new DataAccess.GlobalTransactEntitiesData();
                var trxRecord = globallending.AgentUsers.Where(x => x.AgentID == agtID && x.AgentKey == agtKey).FirstOrDefault();

                string myEmail = "";

                if (trxRecord != null)
                {
                    WebLog.Log("agentID0:" + agentID + " agentKey0:" + agentKey + " signature:" + signature);

                    // myEmail = trxRecord.EmailAddress;
                    myEmail = trxRecord.EmailAddress;
                    string plainText = agentID + agentKey + myEmail;

                    CryptographyManager cryp = new CryptographyManager();

                    if (!cryp.VerifyHash(plainText, signature, HashName.SHA256))
                    {
                        WebLog.Log("VerifyHash error:");
                        return(false);
                    }
                    agObj = trxRecord;
                    WebLog.Log("VerifyHash: sucess:");
                    return(true);
                }
                //  WebLog.Log("agentID2:");
                return(false);
            }
            catch (HttpRequestException ex)
            {
                WebLog.Log(ex.Message + "##AgentTransactController:ValidateCustomerID" + ex.StackTrace);
                WebLog.Log("agentIDx:error here");
                return(false);
            }
        }