Ejemplo n.º 1
0
        public async Task <int> AddAuthorizationRecordAsync(AuthorizeVM vm)
        {
            var RecordDb    = this._dbContext.Set <AuthorizationRecord>();
            var firstRecord = await RecordDb.AsNoTracking().Where(t => t.IsDeleted == false && t.AuthorizeCode == vm.AuthorizeCode).FirstOrDefaultAsync();

            if (firstRecord != null)
            {
                return(-1);
            }
            var record = new AuthorizationRecord()
            {
                AuthorizeCode      = vm.AuthorizeCode,
                AuthorizedTimespan = vm.AuthorizedTimespan.ToString(),
                CreateDate         = DateTime.Now,
                IsDeleted          = false,
                MachineCode        = vm.MachineCode,
                TimespanMonth      = vm.TimespanMonth
            };

            await RecordDb.AddAsync(record);

            int row = await this._dbContext.SaveChangesAsync();

            return(row);
        }
Ejemplo n.º 2
0
        private List <AuthorizationRecord> PopulateAuthorizationRecordsFromElement(Element authorizationsElement)
        {
            if (authorizationsElement.GetElement().ChildNodes.Count > 0)
            {
                List <AuthorizationRecord> authorizationRecordsList = new List <AuthorizationRecord>();
                foreach (Element record in authorizationsElement.GetAll("a:AuthorizationRecord"))
                {
                    var authRecord = new AuthorizationRecord
                    {
                        AddToBatchReferenceNumber = record.GetValue <string>("a:AddToBatchReferenceNumber"),
                        Amount                          = record.GetValue <decimal>("a:Amount"),
                        AuthCode                        = record.GetValue <string>("a:AuthCode"),
                        AuthorizationType               = record.GetValue <string>("a:AuthorizationType"),
                        AvsResultCode                   = record.GetValue <string>("a:AvsResultCode"),
                        AvsResultText                   = record.GetValue <string>("a:AvsResultText"),
                        CardEntryMethod                 = record.GetValue <string>("a:CardEntryMethod"),
                        CvvResultCode                   = record.GetValue <string>("a:CvvResultCode"),
                        CvvResultText                   = record.GetValue <string>("a:CvvResultText"),
                        EmvApplicationCryptogram        = record.GetValue <string>("a:EmvApplicationCryptogram"),
                        EmvApplicationCryptogramType    = record.GetValue <string>("a:EmvApplicationCryptogramType"),
                        EmvApplicationID                = record.GetValue <string>("a:EmvApplicationID"),
                        EmvApplicationName              = record.GetValue <string>("a:EmvApplicationName"),
                        EmvCardholderVerificationMethod = record.GetValue <string>("a:EmvCardholderVerificationMethod"),
                        EmvIssuerResponse               = record.GetValue <string>("a:EmvIssuerResponse"),
                        EmvSignatureRequired            = record.GetValue <string>("a:EmvSignatureRequired"),
                        Gateway                         = record.GetValue <string>("a:Gateway"),
                        GatewayBatchID                  = record.GetValue <string>("a:GatewayBatchID"),
                        GatewayDescription              = record.GetValue <string>("a:GatewayDescription"),
                        MaskedAccountNumber             = record.GetValue <string>("a:MaskedAccountNumber"),
                        MaskedRoutingNumber             = record.GetValue <string>("a:MaskedRoutingNumber"),
                        PaymentMethod                   = record.GetValue <string>("a:PaymentMethod"),
                        ReferenceNumber                 = record.GetValue <string>("a:ReferenceNumber"),
                        RoutingNumber                   = record.GetValue <string>("a:RoutingNumber"),
                        NetAmount                       = record.GetValue <decimal>("a:NetAmount"),
                    };
                    // We are taking this approach for the integers because if the value is null, GetValue is failing the cast
                    string refAuthID = record.GetValue <string>("a:ReferenceAuthorizationID");
                    authRecord.ReferenceAuthorizationID = (!string.IsNullOrWhiteSpace(refAuthID)) ? Convert.ToInt32(refAuthID) : (int?)null;

                    string authID = record.GetValue <string>("a:AuthorizationID");
                    authRecord.AuthorizationID = (!string.IsNullOrWhiteSpace(authID)) ? Convert.ToInt32(authID) : (int?)null;

                    string originalAuthID = record.GetValue <string>("a:OriginalAuthorizationID");
                    authRecord.OriginalAuthorizationID = (!string.IsNullOrWhiteSpace(originalAuthID)) ? Convert.ToInt32(originalAuthID) : (int?)null;

                    authorizationRecordsList.Add(authRecord);
                }
                return(authorizationRecordsList);
            }
            return(null);
        }