Inheritance: System.Web.UI.Page
        public void Test3dsAuthenticatedShouldNotSayItem()
        {
            var auth = new authorization();
            auth.orderId = "12344";
            auth.amount = 2;
            auth.orderSource = orderSourceType.item3dsAuthenticated;
            auth.reportGroup = "Planets";
            var billToAddress = new contact();
            billToAddress.email = "*****@*****.**";
            billToAddress.zip = "12345";
            auth.billToAddress = billToAddress;

            var mock = new Mock<Communications>(_memoryStreams);

            mock.Setup(
                Communications =>
                    Communications.HttpPost(
                        It.IsRegex(".*<amount>2</amount>.*<orderSource>3dsAuthenticated</orderSource>.*",
                            RegexOptions.Singleline), It.IsAny<Dictionary<string, string>>()))
                .Returns(
                    "<litleOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            litle.setCommunication(mockedCommunication);
            var authorizationResponse = litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
        public void EcheckSaleWithEcheckToken()
        {
            var echeckSaleObj = new echeckSale();
            echeckSaleObj.reportGroup = "Planets";
            echeckSaleObj.amount = 123456;
            echeckSaleObj.verify = true;
            echeckSaleObj.orderId = "12345";
            echeckSaleObj.orderSource = orderSourceType.ecommerce;

            var echeckTokenTypeObj = new echeckTokenType();
            echeckTokenTypeObj.accType = echeckAccountTypeEnum.Checking;
            echeckTokenTypeObj.litleToken = "1234565789012";
            echeckTokenTypeObj.routingNum = "123456789";
            echeckTokenTypeObj.checkNum = "123455";

            var customBillingObj = new customBilling();
            customBillingObj.phone = "123456789";
            customBillingObj.descriptor = "good";

            var contactObj = new contact();
            contactObj.name = "Bob";
            contactObj.city = "lowell";
            contactObj.state = "MA";
            contactObj.email = "litle.com";

            echeckSaleObj.token = echeckTokenTypeObj;
            echeckSaleObj.customBilling = customBillingObj;
            echeckSaleObj.billToAddress = contactObj;

            var response = litle.EcheckSale(echeckSaleObj);
            StringAssert.AreEqualIgnoringCase("Approved", response.message);
        }
 public void complexCaptureGivenAuth()
 {
     var capturegivenauth = new captureGivenAuth();
     capturegivenauth.amount = 106;
     capturegivenauth.orderId = "12344";
     var authInfo = new authInformation();
     var authDate = new DateTime(2002, 10, 9);
     authInfo.authDate = authDate;
     authInfo.authCode = "543216";
     authInfo.authAmount = 12345;
     capturegivenauth.authInformation = authInfo;
     var contact = new contact();
     contact.name = "Bob";
     contact.city = "lowell";
     contact.state = "MA";
     contact.email = "litle.com";
     capturegivenauth.billToAddress = contact;
     var processinginstructions = new processingInstructions();
     processinginstructions.bypassVelocityCheck = true;
     capturegivenauth.processingInstructions = processinginstructions;
     capturegivenauth.orderSource = orderSourceType.ecommerce;
     var card = new cardType();
     card.type = methodOfPaymentTypeEnum.VI;
     card.number = "4100000000000000";
     card.expDate = "1210";
     capturegivenauth.card = card;
     var response = litle.CaptureGivenAuth(capturegivenauth);
     Assert.AreEqual("Approved", response.message);
 }
        public void test37()
        {
            var verification = new echeckVerification();
            verification.orderId = "37";
            verification.amount = 3001;
            verification.orderSource = orderSourceType.telephone;
            var billToAddress = new contact();
            billToAddress.firstName = "Tom";
            billToAddress.lastName = "Black";
            verification.billToAddress = billToAddress;
            var echeck = new echeckType();
            echeck.accNum = "10@BC99999";
            echeck.accType = echeckAccountTypeEnum.Checking;
            echeck.routingNum = "053100300";
            verification.echeck = echeck;

            var response = litle.EcheckVerification(verification);
            Assert.AreEqual("301", response.response);
            Assert.AreEqual("Invalid Account Number", response.message);
        }
        public void test32()
        {
            var auth = new authorization();
            auth.orderId = "32";
            auth.amount = 10010;
            auth.orderSource = orderSourceType.ecommerce;
            var billToAddress = new contact();
            billToAddress.name = "John Smith";
            billToAddress.addressLine1 = "1 Main St.";
            billToAddress.city = "Burlington";
            billToAddress.state = "MA";
            billToAddress.zip = "01803-3747";
            billToAddress.country = countryTypeEnum.US;
            auth.billToAddress = billToAddress;
            var card = new cardType();
            card.number = "4457010000000009";
            card.expDate = "0112";
            card.cardValidationNum = "349";
            card.type = methodOfPaymentTypeEnum.VI;
            auth.card = card;

            var authorizeResponse = litle.Authorize(auth);
            Assert.AreEqual("000", authorizeResponse.response);
            Assert.AreEqual("Approved", authorizeResponse.message);
            Assert.AreEqual("11111 ", authorizeResponse.authCode);
            Assert.AreEqual("01", authorizeResponse.fraudResult.avsResult);
            Assert.AreEqual("M", authorizeResponse.fraudResult.cardValidationResult);

            var capture = new capture();
            capture.litleTxnId = authorizeResponse.litleTxnId;
            capture.amount = 5005;
            var captureResponse = litle.Capture(capture);
            Assert.AreEqual("000", captureResponse.response);
            Assert.AreEqual("Approved", captureResponse.message);

            var reversal = new authReversal();
            reversal.litleTxnId = authorizeResponse.litleTxnId;
            var reversalResponse = litle.AuthReversal(reversal);
            Assert.AreEqual("111", reversalResponse.response);
            Assert.AreEqual("Authorization amount has already been depleted", reversalResponse.message);
        }
        public void test38()
        {
            var verification = new echeckVerification();
            verification.orderId = "38";
            verification.amount = 3002;
            verification.orderSource = orderSourceType.telephone;
            var billToAddress = new contact();
            billToAddress.firstName = "John";
            billToAddress.lastName = "Smith";
            billToAddress.phone = "999-999-9999";
            verification.billToAddress = billToAddress;
            var echeck = new echeckType();
            echeck.accNum = "1099999999";
            echeck.accType = echeckAccountTypeEnum.Checking;
            echeck.routingNum = "053000219";
            verification.echeck = echeck;

            var response = litle.EcheckVerification(verification);
            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
        }
 public void echeckCreditWithEcheck()
 {
     var echeckcredit = new echeckCredit();
     echeckcredit.amount = 12L;
     echeckcredit.orderId = "12345";
     echeckcredit.orderSource = orderSourceType.ecommerce;
     var echeck = new echeckType();
     echeck.accType = echeckAccountTypeEnum.Checking;
     echeck.accNum = "12345657890";
     echeck.routingNum = "123456789";
     echeck.checkNum = "123455";
     echeckcredit.echeck = echeck;
     var billToAddress = new contact();
     billToAddress.name = "Bob";
     billToAddress.city = "Lowell";
     billToAddress.state = "MA";
     billToAddress.email = "litle.com";
     echeckcredit.billToAddress = billToAddress;
     var response = litle.EcheckCredit(echeckcredit);
     Assert.AreEqual("Approved", response.message);
 }
Esempio n. 8
0
        public Program()
        {
            m_service = new MockCrmService();
            contact contact = new contact();
            contact.address1_name = "Dan";
            contact.address1_city = "Bethesda";
            Guid id = m_service.Create( contact );

            // data for testing links
            subject subject1 = new subject();
            subject1.title = "parent";
            Guid subject1ID = m_service.Create( subject1 );
            subject subject2 = new subject();
            subject2.title = "child";
            subject2.parentsubject = new Lookup( "subject", subject1ID );
            m_service.Create( subject2 );

            DynamicEntity de = new DynamicEntity();
            de.Name = "mydynamic";
            de.Properties.Add( new StringProperty( "prop1", "foo" ) );
            Guid deID = m_service.Create( de );
        }
Esempio n. 9
0
 public void AuthWithAmpersand()
 {
     var authorization = new authorization();
     authorization.orderId = "1";
     authorization.amount = 10010;
     authorization.orderSource = orderSourceType.ecommerce;
     var contact = new contact();
     contact.name = "John & Jane Smith";
     contact.addressLine1 = "1 Main St.";
     contact.city = "Burlington";
     contact.state = "MA";
     contact.zip = "01803-3747";
     contact.country = countryTypeEnum.US;
     authorization.billToAddress = contact;
     var card = new cardType();
     card.type = methodOfPaymentTypeEnum.VI;
     card.number = "4457010000000009";
     card.expDate = "0112";
     card.cardValidationNum = "349";
     authorization.card = card;
     var response = litle.Authorize(authorization);
     Assert.AreEqual("000", response.response);
 }
        public void TestSimple()
        {
            var update = new updateSubscription();
            update.billingDate = new DateTime(2002, 10, 9);
            var billToAddress = new contact();
            billToAddress.name = "Greg Dake";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "*****@*****.**";
            update.billToAddress = billToAddress;
            var card = new cardType();
            card.number = "4100000000000001";
            card.expDate = "1215";
            card.type = methodOfPaymentTypeEnum.VI;
            update.card = card;
            update.planCode = "abcdefg";
            update.subscriptionId = 12345;

            var mock = new Mock<Communications>(_memoryStreams);

            mock.Setup(
                Communications =>
                    Communications.HttpPost(
                        It.IsRegex(
                            ".*<litleOnlineRequest.*?<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n<planCode>abcdefg</planCode>\r\n<billToAddress>\r\n<name>Greg Dake</name>.*?</billToAddress>\r\n<card>\r\n<type>VI</type>.*?</card>\r\n<billingDate>2002-10-09</billingDate>\r\n</updateSubscription>\r\n</litleOnlineRequest>.*?.*",
                            RegexOptions.Singleline), It.IsAny<Dictionary<string, string>>()))
                .Returns(
                    "<litleOnlineResponse version='8.20' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><updateSubscriptionResponse ><litleTxnId>456</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04</responseTime><subscriptionId>12345</subscriptionId></updateSubscriptionResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            litle.setCommunication(mockedCommunication);
            var response = litle.UpdateSubscription(update);
            Assert.AreEqual("12345", response.subscriptionId);
            Assert.AreEqual("456", response.litleTxnId);
            Assert.AreEqual("000", response.response);
            Assert.NotNull(response.responseTime);
        }
 base.PostSolve(contact, impulse);
        public void test8Sale()
        {
            var sale = new sale();
            sale.orderId = "8";
            sale.amount = 80080;
            sale.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Mark Johnson";
            contact.addressLine1 = "8 Main St.";
            contact.city = "Manchester";
            contact.state = "NH";
            contact.zip = "03101";
            contact.country = countryTypeEnum.US;
            sale.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.DI;
            card.number = "6011010100000002";
            card.expDate = "0812";
            card.cardValidationNum = "184";
            sale.card = card;

            var response = litle.Sale(sale);
            Assert.AreEqual("123", response.response);
            Assert.AreEqual("Call Discover", response.message);
            Assert.AreEqual("34", response.fraudResult.avsResult);
            Assert.AreEqual("P", response.fraudResult.cardValidationResult);
        }
 public void Back()
 {
     MessengerInstance.Send(new HistoryMessage());
     Contact         = new contact();
     Contact.address = new address();
 }
        public void test4Sale()
        {
            var sale = new sale();
            sale.orderId = "4";
            sale.amount = 40040;
            sale.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Bob Black";
            contact.addressLine1 = "4 Main St.";
            contact.city = "Laurel";
            contact.state = "MD";
            contact.zip = "20708";
            contact.country = countryTypeEnum.US;
            sale.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.AX;
            card.number = "375001000000005";
            card.expDate = "0412";
            card.cardValidationNum = "758";
            sale.card = card;

            var response = litle.Sale(sale);
            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("44444", response.authCode);
            Assert.AreEqual("12", response.fraudResult.avsResult);

            var credit = new credit();
            credit.litleTxnId = response.litleTxnId;
            var creditResponse = litle.Credit(credit);
            Assert.AreEqual("000", creditResponse.response);
            Assert.AreEqual("Approved", creditResponse.message);

            var newvoid = new voidTxn();
            newvoid.litleTxnId = creditResponse.litleTxnId;
            var voidResponse = litle.DoVoid(newvoid);
            Assert.AreEqual("000", voidResponse.response);
            Assert.AreEqual("Approved", voidResponse.message);
        }
        public void test6Sale()
        {
            var sale = new sale();
            sale.orderId = "6";
            sale.amount = 60060;
            sale.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Joe Green";
            contact.addressLine1 = "6 Main St.";
            contact.city = "Derry";
            contact.state = "NH";
            contact.zip = "03038";
            contact.country = countryTypeEnum.US;
            sale.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4457010100000008";
            card.expDate = "0612";
            card.cardValidationNum = "992";
            sale.card = card;

            var response = litle.Sale(sale);
            Assert.AreEqual("110", response.response);
            Assert.AreEqual("Insufficient Funds", response.message);
            Assert.AreEqual("34", response.fraudResult.avsResult);
            Assert.AreEqual("P", response.fraudResult.cardValidationResult);

            var newvoid = new voidTxn();
            newvoid.litleTxnId = response.litleTxnId;
            var voidResponse = litle.DoVoid(newvoid);
            Assert.AreEqual("360", voidResponse.response);
            Assert.AreEqual("No transaction found with specified litleTxnId", voidResponse.message);
        }
Esempio n. 16
0
 AssertEquals(contact.details.title, "Some Title");
Esempio n. 17
0
 /// <summary>
 /// Create Contact
 /// </summary>
 public void AddContact(contact contact)
 {
     dbConnection.contacts.Add(contact);
 }
Esempio n. 18
0
 public void UpdateContact(contact contact)
 {
     Contact = contact;
     RaisePropertyChanged("Contact");
 }
 public void Create(contact entity)
 {
     _unitOfWork.ContactRepository.Insert(entity);
     _unitOfWork.Save();
     _unitOfWork.Commit();
 }
Esempio n. 20
0
 //
 public void remove(contact contact)
 {
     _repository.remove(contact);
 }
Esempio n. 21
0
        public void TestSimpleBatchPgp()
        {
            _cnp = new cnpRequest(_config);
            batchRequest cnpBatchRequest = new batchRequest(_config);

            Console.WriteLine("Merchant Id:" + cnpBatchRequest.config["merchantId"]);
            Console.WriteLine("Merchant Username:"******"username"]);
            Console.WriteLine("Merchant Password:"******"password"]);
            Console.WriteLine("Length of Password:"******"password"].Length);
            var authorization = new authorization
            {
                reportGroup = "Planets",
                orderId     = "12344",
                amount      = 106,
                orderSource = orderSourceType.ecommerce
            };
            var card = new cardType
            {
                type    = methodOfPaymentTypeEnum.VI,
                number  = "4100000000000001",
                expDate = "1210"
            };

            authorization.card = card;
            authorization.id   = "id";

            cnpBatchRequest.addAuthorization(authorization);

            var authorization2 = new authorization();

            authorization2.reportGroup = "Planets";
            authorization2.orderId     = "12345";
            authorization2.amount      = 106;
            authorization2.orderSource = orderSourceType.ecommerce;
            var card2 = new cardType();

            card2.type          = methodOfPaymentTypeEnum.VI;
            card2.number        = "4242424242424242";
            card2.expDate       = "1210";
            authorization2.card = card2;
            authorization2.id   = "id";

            cnpBatchRequest.addAuthorization(authorization2);

            var reversal = new authReversal();

            reversal.cnpTxnId    = 12345678000L;
            reversal.amount      = 106;
            reversal.payPalNotes = "Notes";
            reversal.id          = "id";

            cnpBatchRequest.addAuthReversal(reversal);

            var reversal2 = new authReversal();

            reversal2.cnpTxnId    = 12345678900L;
            reversal2.amount      = 106;
            reversal2.payPalNotes = "Notes";
            reversal2.id          = "id";

            cnpBatchRequest.addAuthReversal(reversal2);

            var giftCardAuthReversal = new giftCardAuthReversal();

            giftCardAuthReversal.id       = "id";
            giftCardAuthReversal.cnpTxnId = 12345678000L;
            var giftCardCardTypeAuthReversal = new giftCardCardType();

            giftCardCardTypeAuthReversal.type           = methodOfPaymentTypeEnum.GC;
            giftCardCardTypeAuthReversal.number         = "4100000000000001";
            giftCardCardTypeAuthReversal.expDate        = "1210";
            giftCardAuthReversal.card                   = giftCardCardTypeAuthReversal;
            giftCardAuthReversal.originalRefCode        = "123456";
            giftCardAuthReversal.originalAmount         = 1000;
            giftCardAuthReversal.originalTxnTime        = DateTime.Now;
            giftCardAuthReversal.originalSystemTraceId  = 123;
            giftCardAuthReversal.originalSequenceNumber = "123456";

            cnpBatchRequest.addGiftCardAuthReversal(giftCardAuthReversal);

            var capture = new capture();

            capture.cnpTxnId    = 123456000;
            capture.amount      = 106;
            capture.payPalNotes = "Notes";
            capture.id          = "id";

            cnpBatchRequest.addCapture(capture);

            var capture2 = new capture();

            capture2.cnpTxnId    = 123456700;
            capture2.amount      = 106;
            capture2.payPalNotes = "Notes";
            capture2.id          = "id";

            cnpBatchRequest.addCapture(capture2);

            var giftCardCapture = new giftCardCapture();

            giftCardCapture.id            = "id";
            giftCardCapture.cnpTxnId      = 12345678000L;
            giftCardCapture.captureAmount = 123456;
            var giftCardCardTypeCapture = new giftCardCardType();

            giftCardCardTypeCapture.type    = methodOfPaymentTypeEnum.GC;
            giftCardCardTypeCapture.number  = "4100000000000001";
            giftCardCardTypeCapture.expDate = "1210";
            giftCardCapture.card            = giftCardCardTypeCapture;
            giftCardCapture.originalRefCode = "123456";
            giftCardCapture.originalAmount  = 1000;
            giftCardCapture.originalTxnTime = DateTime.Now;

            cnpBatchRequest.addGiftCardCapture(giftCardCapture);

            var capturegivenauth = new captureGivenAuth();

            capturegivenauth.amount  = 106;
            capturegivenauth.orderId = "12344";
            var authInfo = new authInformation();
            var authDate = new DateTime(2002, 10, 9);

            authInfo.authDate   = authDate;
            authInfo.authCode   = "543216";
            authInfo.authAmount = 12345;
            capturegivenauth.authInformation = authInfo;
            capturegivenauth.orderSource     = orderSourceType.ecommerce;
            capturegivenauth.card            = card;
            capturegivenauth.id = "id";

            cnpBatchRequest.addCaptureGivenAuth(capturegivenauth);

            var capturegivenauth2 = new captureGivenAuth();

            capturegivenauth2.amount  = 106;
            capturegivenauth2.orderId = "12344";
            var authInfo2 = new authInformation();

            authDate             = new DateTime(2003, 10, 9);
            authInfo2.authDate   = authDate;
            authInfo2.authCode   = "543216";
            authInfo2.authAmount = 12345;
            capturegivenauth2.authInformation = authInfo;
            capturegivenauth2.orderSource     = orderSourceType.ecommerce;
            capturegivenauth2.card            = card2;
            capturegivenauth2.id = "id";

            cnpBatchRequest.addCaptureGivenAuth(capturegivenauth2);

            var creditObj = new credit();

            creditObj.amount      = 106;
            creditObj.orderId     = "2111";
            creditObj.orderSource = orderSourceType.ecommerce;
            creditObj.card        = card;
            creditObj.id          = "id";

            cnpBatchRequest.addCredit(creditObj);

            var creditObj2 = new credit();

            creditObj2.amount      = 106;
            creditObj2.orderId     = "2111";
            creditObj2.orderSource = orderSourceType.ecommerce;
            creditObj2.card        = card2;
            creditObj2.id          = "id";

            cnpBatchRequest.addCredit(creditObj2);

            var giftCardCredit = new giftCardCredit();

            giftCardCredit.id           = "id";
            giftCardCredit.cnpTxnId     = 12345678000L;
            giftCardCredit.creditAmount = 123456;
            var giftCardCardTypeCredit = new giftCardCardType();

            giftCardCardTypeCredit.type    = methodOfPaymentTypeEnum.GC;
            giftCardCardTypeCredit.number  = "4100000000000001";
            giftCardCardTypeCredit.expDate = "1210";
            giftCardCredit.card            = giftCardCardTypeCredit;
            giftCardCredit.orderId         = "123456";
            giftCardCredit.orderSource     = orderSourceType.ecommerce;

            cnpBatchRequest.addGiftCardCredit(giftCardCredit);

            var echeckcredit = new echeckCredit();

            echeckcredit.amount      = 12L;
            echeckcredit.orderId     = "12345";
            echeckcredit.orderSource = orderSourceType.ecommerce;
            var echeck = new echeckType();

            echeck.accType      = echeckAccountTypeEnum.Checking;
            echeck.accNum       = "1099999903";
            echeck.routingNum   = "011201995";
            echeck.checkNum     = "123455";
            echeckcredit.echeck = echeck;
            var billToAddress = new contact();

            billToAddress.name         = "Bob";
            billToAddress.city         = "Lowell";
            billToAddress.state        = "MA";
            billToAddress.email        = "cnp.com";
            echeckcredit.billToAddress = billToAddress;
            echeckcredit.id            = "id";

            cnpBatchRequest.addEcheckCredit(echeckcredit);

            var echeckcredit2 = new echeckCredit();

            echeckcredit2.amount      = 12L;
            echeckcredit2.orderId     = "12346";
            echeckcredit2.orderSource = orderSourceType.ecommerce;
            var echeck2 = new echeckType();

            echeck2.accType      = echeckAccountTypeEnum.Checking;
            echeck2.accNum       = "1099999903";
            echeck2.routingNum   = "011201995";
            echeck2.checkNum     = "123456";
            echeckcredit2.echeck = echeck2;
            var billToAddress2 = new contact();

            billToAddress2.name         = "Mike";
            billToAddress2.city         = "Lowell";
            billToAddress2.state        = "MA";
            billToAddress2.email        = "cnp.com";
            echeckcredit2.billToAddress = billToAddress2;
            echeckcredit2.id            = "id";

            cnpBatchRequest.addEcheckCredit(echeckcredit2);

            var echeckredeposit = new echeckRedeposit();

            echeckredeposit.cnpTxnId = 123456;
            echeckredeposit.echeck   = echeck;
            echeckredeposit.id       = "id";

            cnpBatchRequest.addEcheckRedeposit(echeckredeposit);

            var echeckredeposit2 = new echeckRedeposit();

            echeckredeposit2.cnpTxnId = 123457;
            echeckredeposit2.echeck   = echeck2;
            echeckredeposit2.id       = "id";

            cnpBatchRequest.addEcheckRedeposit(echeckredeposit2);

            var echeckSaleObj = new echeckSale();

            echeckSaleObj.amount        = 123456;
            echeckSaleObj.orderId       = "12345";
            echeckSaleObj.orderSource   = orderSourceType.ecommerce;
            echeckSaleObj.echeck        = echeck;
            echeckSaleObj.billToAddress = billToAddress;
            echeckSaleObj.id            = "id";

            cnpBatchRequest.addEcheckSale(echeckSaleObj);

            var echeckSaleObj2 = new echeckSale();

            echeckSaleObj2.amount        = 123456;
            echeckSaleObj2.orderId       = "12346";
            echeckSaleObj2.orderSource   = orderSourceType.ecommerce;
            echeckSaleObj2.echeck        = echeck2;
            echeckSaleObj2.billToAddress = billToAddress2;
            echeckSaleObj2.id            = "id";

            cnpBatchRequest.addEcheckSale(echeckSaleObj2);

            var echeckPreNoteSaleObj1 = new echeckPreNoteSale();

            echeckPreNoteSaleObj1.orderId       = "12345";
            echeckPreNoteSaleObj1.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteSaleObj1.echeck        = echeck;
            echeckPreNoteSaleObj1.billToAddress = billToAddress;
            echeckPreNoteSaleObj1.id            = "id";

            cnpBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleObj1);

            var echeckPreNoteSaleObj2 = new echeckPreNoteSale();

            echeckPreNoteSaleObj2.orderId       = "12345";
            echeckPreNoteSaleObj2.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteSaleObj2.echeck        = echeck2;
            echeckPreNoteSaleObj2.billToAddress = billToAddress2;
            echeckPreNoteSaleObj2.id            = "id";

            cnpBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleObj2);

            var echeckPreNoteCreditObj1 = new echeckPreNoteCredit();

            echeckPreNoteCreditObj1.orderId       = "12345";
            echeckPreNoteCreditObj1.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteCreditObj1.echeck        = echeck;
            echeckPreNoteCreditObj1.billToAddress = billToAddress;
            echeckPreNoteCreditObj1.id            = "id";

            cnpBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditObj1);

            var echeckPreNoteCreditObj2 = new echeckPreNoteCredit();

            echeckPreNoteCreditObj2.orderId       = "12345";
            echeckPreNoteCreditObj2.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteCreditObj2.echeck        = echeck2;
            echeckPreNoteCreditObj2.billToAddress = billToAddress2;
            echeckPreNoteCreditObj2.id            = "id";

            var echeckVerificationObject = new echeckVerification();

            echeckVerificationObject.amount        = 123456;
            echeckVerificationObject.orderId       = "12345";
            echeckVerificationObject.orderSource   = orderSourceType.ecommerce;
            echeckVerificationObject.echeck        = echeck;
            echeckVerificationObject.billToAddress = billToAddress;
            echeckVerificationObject.id            = "id";

            cnpBatchRequest.addEcheckVerification(echeckVerificationObject);

            var echeckVerificationObject2 = new echeckVerification();

            echeckVerificationObject2.amount        = 123456;
            echeckVerificationObject2.orderId       = "12346";
            echeckVerificationObject2.orderSource   = orderSourceType.ecommerce;
            echeckVerificationObject2.echeck        = echeck2;
            echeckVerificationObject2.billToAddress = billToAddress2;
            echeckVerificationObject2.id            = "id";

            cnpBatchRequest.addEcheckVerification(echeckVerificationObject2);

            var forcecapture = new forceCapture();

            forcecapture.amount      = 106;
            forcecapture.orderId     = "12344";
            forcecapture.orderSource = orderSourceType.ecommerce;
            forcecapture.card        = card;
            forcecapture.id          = "id";

            cnpBatchRequest.addForceCapture(forcecapture);

            var forcecapture2 = new forceCapture();

            forcecapture2.amount      = 106;
            forcecapture2.orderId     = "12345";
            forcecapture2.orderSource = orderSourceType.ecommerce;
            forcecapture2.card        = card2;
            forcecapture2.id          = "id";

            cnpBatchRequest.addForceCapture(forcecapture2);

            var saleObj = new sale();

            saleObj.amount      = 106;
            saleObj.cnpTxnId    = 123456;
            saleObj.orderId     = "12344";
            saleObj.orderSource = orderSourceType.ecommerce;
            saleObj.card        = card;
            saleObj.id          = "id";

            cnpBatchRequest.addSale(saleObj);

            var saleObj2 = new sale();

            saleObj2.amount      = 106;
            saleObj2.cnpTxnId    = 123456;
            saleObj2.orderId     = "12345";
            saleObj2.orderSource = orderSourceType.ecommerce;
            saleObj2.card        = card2;
            saleObj2.id          = "id";

            cnpBatchRequest.addSale(saleObj2);

            var registerTokenRequest = new registerTokenRequestType();

            registerTokenRequest.orderId       = "12344";
            registerTokenRequest.accountNumber = "1233456789103801";
            registerTokenRequest.reportGroup   = "Planets";
            registerTokenRequest.id            = "id";

            cnpBatchRequest.addRegisterTokenRequest(registerTokenRequest);

            var registerTokenRequest2 = new registerTokenRequestType();

            registerTokenRequest2.orderId       = "12345";
            registerTokenRequest2.accountNumber = "1233456789103801";
            registerTokenRequest2.reportGroup   = "Planets";
            registerTokenRequest2.id            = "id";

            cnpBatchRequest.addRegisterTokenRequest(registerTokenRequest2);

            var updateCardValidationNumOnToken = new updateCardValidationNumOnToken();

            updateCardValidationNumOnToken.orderId           = "12344";
            updateCardValidationNumOnToken.cardValidationNum = "123";
            updateCardValidationNumOnToken.cnpToken          = "4100000000000001";
            updateCardValidationNumOnToken.id = "id";

            cnpBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken);

            var updateCardValidationNumOnToken2 = new updateCardValidationNumOnToken();

            updateCardValidationNumOnToken2.orderId           = "12345";
            updateCardValidationNumOnToken2.cardValidationNum = "123";
            updateCardValidationNumOnToken2.cnpToken          = "4242424242424242";
            updateCardValidationNumOnToken2.id = "id";

            cnpBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken2);
            _cnp.addBatch(cnpBatchRequest);


            string batchName = _cnp.sendToCnp();

            //Check if the .xml batch request file exists inside "Requests" directory
            var requestDir  = _cnp.getRequestDirectory();
            var entries     = Directory.EnumerateFiles(requestDir);
            var targetEntry = Path.Combine(requestDir, batchName.Replace(".encrypted", ""));

            Assert.True(entries.Contains(targetEntry));

            // check if "encrypted" directory is present inside "Requests" directory
            var encryptedRequestDir = Path.Combine(requestDir, "encrypted");

            Assert.True(Directory.Exists(encryptedRequestDir));

            //Check if the .xml.encrypted batch request file exists inside "Requests/encrypted" directory
            entries     = Directory.EnumerateFiles(encryptedRequestDir);
            targetEntry = Path.Combine(encryptedRequestDir, batchName);
            Assert.True(entries.Contains(targetEntry));

            _cnp.blockAndWaitForResponse(batchName, estimatedResponseTime(2 * 2, 10 * 2));

            cnpResponse cnpResponse = _cnp.receiveFromCnp(batchName);

            //Check if the .xml batch response file exists inside "Responses" directory
            var responseDir = _cnp.getResponseDirectory();

            entries     = Directory.EnumerateFiles(responseDir);
            targetEntry = Path.Combine(responseDir, batchName.Replace(".encrypted", ""));
            Assert.True(entries.Contains(targetEntry));

            // check if "encrypted" directory is present inside "Responses" directory
            var encryptedResponseDir = Path.Combine(responseDir, "encrypted");

            Assert.True(Directory.Exists(encryptedResponseDir));

            //Check if the .xml.encrypted batch response file exists inside "Responses/encrypted" directory
            entries     = Directory.EnumerateFiles(encryptedResponseDir);
            targetEntry = Path.Combine(encryptedResponseDir, batchName);
            Assert.True(entries.Contains(targetEntry));

            Assert.NotNull(cnpResponse);
            Assert.AreEqual("0", cnpResponse.response);
            Assert.AreEqual("Valid Format", cnpResponse.message);

            var cnpBatchResponse = cnpResponse.nextBatchResponse();

            while (cnpBatchResponse != null)
            {
                var authorizationResponse = cnpBatchResponse.nextAuthorizationResponse();
                while (authorizationResponse != null)
                {
                    Assert.AreEqual("000", authorizationResponse.response);

                    authorizationResponse = cnpBatchResponse.nextAuthorizationResponse();
                }

                var authReversalResponse = cnpBatchResponse.nextAuthReversalResponse();
                while (authReversalResponse != null)
                {
                    Assert.AreEqual("000", authReversalResponse.response);

                    authReversalResponse = cnpBatchResponse.nextAuthReversalResponse();
                }

                var giftCardAuthReversalResponse = cnpBatchResponse.nextGiftCardAuthReversalResponse();
                while (giftCardAuthReversalResponse != null)
                {
                    Assert.NotNull(giftCardAuthReversalResponse.response);

                    giftCardAuthReversalResponse = cnpBatchResponse.nextGiftCardAuthReversalResponse();
                }

                var captureResponse = cnpBatchResponse.nextCaptureResponse();
                while (captureResponse != null)
                {
                    Assert.AreEqual("000", captureResponse.response);

                    captureResponse = cnpBatchResponse.nextCaptureResponse();
                }

                var giftCardCaptureResponse = cnpBatchResponse.nextGiftCardCaptureResponse();
                while (giftCardCaptureResponse != null)
                {
                    Assert.NotNull(giftCardCaptureResponse.response);

                    giftCardCaptureResponse = cnpBatchResponse.nextGiftCardCaptureResponse();
                }


                var captureGivenAuthResponse = cnpBatchResponse.nextCaptureGivenAuthResponse();
                while (captureGivenAuthResponse != null)
                {
                    Assert.AreEqual("000", captureGivenAuthResponse.response);

                    captureGivenAuthResponse = cnpBatchResponse.nextCaptureGivenAuthResponse();
                }

                var creditResponse = cnpBatchResponse.nextCreditResponse();
                while (creditResponse != null)
                {
                    Assert.AreEqual("000", creditResponse.response);

                    creditResponse = cnpBatchResponse.nextCreditResponse();
                }

                var giftCardCreditResponse = cnpBatchResponse.nextGiftCardCreditResponse();
                while (giftCardCreditResponse != null)
                {
                    Assert.NotNull(giftCardCreditResponse.response);

                    giftCardCreditResponse = cnpBatchResponse.nextGiftCardCreditResponse();
                }

                var echeckCreditResponse = cnpBatchResponse.nextEcheckCreditResponse();
                while (echeckCreditResponse != null)
                {
                    Assert.AreEqual("000", echeckCreditResponse.response);

                    echeckCreditResponse = cnpBatchResponse.nextEcheckCreditResponse();
                }

                var echeckRedepositResponse = cnpBatchResponse.nextEcheckRedepositResponse();
                while (echeckRedepositResponse != null)
                {
                    Assert.AreEqual("000", echeckRedepositResponse.response);

                    echeckRedepositResponse = cnpBatchResponse.nextEcheckRedepositResponse();
                }

                var echeckSalesResponse = cnpBatchResponse.nextEcheckSalesResponse();
                while (echeckSalesResponse != null)
                {
                    Assert.AreEqual("000", echeckSalesResponse.response);

                    echeckSalesResponse = cnpBatchResponse.nextEcheckSalesResponse();
                }

                var echeckPreNoteSaleResponse = cnpBatchResponse.nextEcheckPreNoteSaleResponse();
                while (echeckPreNoteSaleResponse != null)
                {
                    Assert.AreEqual("000", echeckPreNoteSaleResponse.response);

                    echeckPreNoteSaleResponse = cnpBatchResponse.nextEcheckPreNoteSaleResponse();
                }

                var echeckPreNoteCreditResponse = cnpBatchResponse.nextEcheckPreNoteCreditResponse();
                while (echeckPreNoteCreditResponse != null)
                {
                    Assert.AreEqual("000", echeckPreNoteCreditResponse.response);

                    echeckPreNoteCreditResponse = cnpBatchResponse.nextEcheckPreNoteCreditResponse();
                }

                var echeckVerificationResponse = cnpBatchResponse.nextEcheckVerificationResponse();
                while (echeckVerificationResponse != null)
                {
                    Assert.AreEqual("957", echeckVerificationResponse.response);

                    echeckVerificationResponse = cnpBatchResponse.nextEcheckVerificationResponse();
                }

                var forceCaptureResponse = cnpBatchResponse.nextForceCaptureResponse();
                while (forceCaptureResponse != null)
                {
                    Assert.AreEqual("000", forceCaptureResponse.response);

                    forceCaptureResponse = cnpBatchResponse.nextForceCaptureResponse();
                }

                var registerTokenResponse = cnpBatchResponse.nextRegisterTokenResponse();
                while (registerTokenResponse != null)
                {
                    Assert.AreEqual("820", registerTokenResponse.response);

                    registerTokenResponse = cnpBatchResponse.nextRegisterTokenResponse();
                }

                var saleResponse = cnpBatchResponse.nextSaleResponse();
                while (saleResponse != null)
                {
                    Assert.AreEqual("000", saleResponse.response);

                    saleResponse = cnpBatchResponse.nextSaleResponse();
                }
                cnpBatchResponse = cnpResponse.nextBatchResponse();
            }
        }
Esempio n. 22
0
 /// <summary>
 ///
 /// </summasiry>
 /// <param name="contact"></param>
 public void create(contact contact)
 {
     _repository.add(contact);
 }
Esempio n. 23
0
        public contact AddContact(string firstName, string lastName, string email, string address, string homePhone, string officePhone, string street, string city,
                                  string zipCode, string state, string country, string organization, string designation, string photo, Nullable <bool> allowNewsLetter, string Comment,
                                  out TransactionalInformation transaction)
        {
            transaction = new TransactionalInformation();
            ContactBusinessRules contactRules = new ContactBusinessRules();

            contact objContact = new contact();

            try
            {
                //if(!string.IsNullOrEmpty(objContact.FirstName)) objContact.FirstName = Utilities.UppercaseFirstLetter(firstName.Trim());
                //if(!string.IsNullOrEmpty(objContact.LastName)) objContact.LastName = Utilities.UppercaseFirstLetter(lastName.Trim());
                objContact.FirstName       = firstName;
                objContact.LastName        = lastName;
                objContact.Email           = email;
                objContact.Address         = address;
                objContact.HomePhone       = homePhone;
                objContact.OfficePhone     = officePhone;
                objContact.Street          = street;
                objContact.City            = city;
                objContact.Zipcode         = zipCode;
                objContact.State           = state;
                objContact.Country         = country;
                objContact.Organization    = organization;
                objContact.Designation     = designation;
                objContact.Photo           = photo;
                objContact.AllowNewsLetter = allowNewsLetter;
                objContact.Comments        = Comment;
                objContact.Responded       = false;
                objContact.CreateDate      = System.DateTime.Now;

                ContactsDataService.CreateSession();
                contactRules.ValidateContact(objContact, ContactsDataService);

                if (contactRules.ValidationStatus == true)
                {
                    ContactsDataService.BeginTransaction();
                    ContactsDataService.AddContact(objContact);
                    ContactsDataService.CommitTransaction(true);
                    transaction.ReturnStatus = true;
                    transaction.ReturnMessage.Add("Contact added successfully.");
                }
                else
                {
                    transaction.ReturnStatus     = contactRules.ValidationStatus;
                    transaction.ReturnMessage    = contactRules.ValidationMessage;
                    transaction.ValidationErrors = contactRules.ValidationErrors;
                }
                //Send Email
                //EmailSender.SendEmail("*****@*****.**", "New Contact Request", objContact.Comments, true);
            }
            catch (Exception ex)
            {
                WebUtils.TransactionException(transaction, ex);
            }
            finally
            {
                ContactsDataService.CloseSession();
            }

            return(objContact);
        }
Esempio n. 24
0
 public void UpdateContact(contact contact)
 {
     dbConnection.contacts.Add(contact);
 }
Esempio n. 25
0
        public void sales()
        {
            string sql = " SELECT "
                         + " dbo.VENTAS.CODVENTA, dbo.VENTAS.NUMVENTA, dbo.VENTAS.FECHAVENTA, dbo.VENTAS.PORCENTAJEDESCUENTO,"
                         + " dbo.VENTAS.TOTALEXENTA, dbo.VENTAS.TOTALGRAVADA, dbo.VENTAS.TOTALIVA, dbo.VENTAS.TOTALDESCUENTO,"
                         + " dbo.VENTAS.MODALIDADPAGO, dbo.VENTAS.FECGRA, dbo.VENTAS.ESTADO, dbo.VENTAS.MOTIVOANULADO,"
                         + " dbo.VENTAS.FECHAANULADO, dbo.VENTAS.TIPOVENTA, dbo.VENTAS.TIPOPRECIO, dbo.VENTAS.NUMVENTATIMBRADO,"
                         + " dbo.VENTAS.TOTAL5, dbo.VENTAS.TOTAL10, dbo.VENTAS.CODPRESUPUESTO, dbo.VENTAS.METODO, dbo.VENTAS.ENVIADO,"
                         + " dbo.VENTAS.TOTALGRAVADO5, dbo.VENTAS.TOTALGRAVADO10, dbo.VENTAS.ASENTADO,"
                         + " dbo.VENTAS.TOTALVENTA, dbo.VENDEDOR.DESVENDEDOR, dbo.CLIENTES.NOMBRE, dbo.CLIENTES.RUC,"
                         + " dbo.SUCURSAL.DESSUCURSAL, dbo.VENTAS.COTIZACION1, FACTURACOBRAR_1.FECHAVCTO,"
                         + " dbo.FACTURACOBRAR.FECHAVCTO AS Expr1, dbo.FACTURACOBRAR.SALDOCUOTA, dbo.FACTURACOBRAR.IMPORTECUOTA, "
                         + " dbo.FACTURACOBRAR.COTIZACION, dbo.VENTASFORMACOBRO.IMPORTE, dbo.VENTASFORMACOBRO.DESTIPOCOBRO,"
                         + " dbo.VENTASFORMACOBRO.NUMDEVOLUCION, dbo.VENTASFORMACOBRO.TIPOCOBRO"
                         + " FROM  dbo.SUCURSAL RIGHT OUTER JOIN"
                         + " dbo.FACTURACOBRAR RIGHT OUTER JOIN"
                         + " dbo.VENTAS ON dbo.FACTURACOBRAR.CODVENTA = dbo.VENTAS.CODVENTA LEFT OUTER JOIN"
                         + " dbo.VENTASFORMACOBRO ON dbo.VENTAS.CODVENTA = dbo.VENTASFORMACOBRO.CODVENTA ON dbo.SUCURSAL.CODSUCURSAL = dbo.VENTAS.CODSUCURSAL"
                         + " LEFT OUTER JOIN dbo.VENDEDOR ON dbo.VENTAS.CODVENDEDOR = dbo.VENDEDOR.CODVENDEDOR LEFT OUTER JOIN"
                         + " dbo.CLIENTES ON dbo.VENTAS.CODCLIENTE = dbo.CLIENTES.CODCLIENTE LEFT OUTER JOIN"
                         + " dbo.FACTURACOBRAR AS FACTURACOBRAR_1 ON dbo.VENTAS.CODVENTA = FACTURACOBRAR_1.CODVENTA";

            SqlConnection conn = new SqlConnection(_connString);

            //Counts Total number of Rows we have to process
            SqlCommand cmd = new SqlCommand(sql, conn);

            conn.Open();
            cmd.CommandType = CommandType.Text;
            DataTable dt_sales = exeDT(sql);
            int       count    = (int)dt_sales.Rows.Count;

            conn.Close();

            int value = 0;

            Dispatcher.BeginInvoke((Action)(() => salesMaximum.Text = count.ToString()));
            Dispatcher.BeginInvoke((Action)(() => salesValue.Text = value.ToString()));
            Dispatcher.BeginInvoke((Action)(() => progSales.Maximum = count));
            Dispatcher.BeginInvoke((Action)(() => progSales.Value = value));

            //Sales Invoice Detail
            string sqlDetail = "SELECT"
                               + " dbo.PRODUCTOS.DESPRODUCTO,"           //0
                               + " dbo.VENTASDETALLE.CANTIDADVENTA,"     //1
                               + " dbo.VENTASDETALLE.PRECIOVENTANETO, "  //2
                               + " dbo.VENTASDETALLE.PRECIOVENTALISTA, " //3
                               + " dbo.VENTASDETALLE.COSTOPROMEDIO, "    //4
                               + " dbo.VENTASDETALLE.COSTOULTIMO, "      //5
                               + " dbo.VENTASDETALLE.IVA, "              //6
                               + " dbo.VENTAS.COTIZACION1, "             //7
                               + " dbo.MONEDA.DESMONEDA, "               //8
                               + " dbo.VENTASDETALLE.CODVENTA"
                               + " FROM dbo.VENTAS LEFT OUTER JOIN"
                               + " dbo.MONEDA ON dbo.VENTAS.CODMONEDA = dbo.MONEDA.CODMONEDA LEFT OUTER JOIN"
                               + " dbo.VENTASDETALLE ON dbo.VENTAS.CODVENTA = dbo.VENTASDETALLE.CODVENTA LEFT OUTER JOIN"
                               + " dbo.PRODUCTOS ON dbo.VENTASDETALLE.CODPRODUCTO = dbo.PRODUCTOS.CODPRODUCTO";

            DataTable dt_detail = exeDT(sqlDetail);

            int RoofValue  = 1000;
            int FloorValue = 0;

            //Run a Foreach Lap
            for (int i = FloorValue; i < RoofValue; i++)
            {
                using (SalesInvoiceDB db = new SalesInvoiceDB())
                {
                    db.Configuration.AutoDetectChangesEnabled = false;

                    List <entity.app_vat_group>  VATGroupList       = db.app_vat_group.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.contact>        ContactList        = db.contacts.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.sales_rep>      sales_repList      = db.sales_rep.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.app_branch>     BranchList         = db.app_branch.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.app_location>   LocationList       = db.app_location.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.app_terminal>   TerminalList       = db.app_terminal.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.item>           ItemList           = db.items.Where(x => x.id_company == CurrentSession.Id_Company).ToList();
                    List <entity.app_currencyfx> app_currencyfxList = db.app_currencyfx.Where(x => x.id_company == CurrentSession.Id_Company).ToList();

                    app_condition  app_conditionCrédito = db.app_condition.Where(x => x.name == "Crédito" && x.id_company == id_company).FirstOrDefault();
                    app_condition  app_conditionContado = db.app_condition.Where(x => x.name == "Contado" && x.id_company == id_company).FirstOrDefault();
                    app_currencyfx app_currencyfx       = null;
                    if (app_currencyfxList.Where(x => x.is_active).FirstOrDefault() != null)
                    {
                        app_currencyfx = app_currencyfxList.Where(x => x.is_active).FirstOrDefault();
                    }

                    app_vat_group app_vat_group10 = VATGroupList.Where(x => x.name.Contains("10")).FirstOrDefault();
                    app_vat_group app_vat_group5  = VATGroupList.Where(x => x.name.Contains("5")).FirstOrDefault();
                    app_vat_group app_vat_group0  = VATGroupList.Where(x => x.name.Contains("0")).FirstOrDefault();


                    foreach (DataRow InnerRow in dt_sales.Select("CODVENTA > " + FloorValue + " AND CODVENTA < " + RoofValue + ""))
                    {
                        sales_invoice sales_invoice = new entity.sales_invoice();
                        sales_invoice.State      = EntityState.Added;
                        sales_invoice.status     = Status.Documents_General.Pending;
                        sales_invoice.IsSelected = true;
                        sales_invoice.trans_type = Status.TransactionTypes.Normal;
                        sales_invoice.trans_date = DateTime.Now.AddDays(0);
                        sales_invoice.timestamp  = DateTime.Now;
                        sales_invoice.id_company = id_company;
                        sales_invoice.number     = (InnerRow["NUMVENTA"] is DBNull) ? null : InnerRow["NUMVENTA"].ToString();

                        sales_invoice.trans_date = (InnerRow["FECHAVENTA"] is DBNull) ? DateTime.Now :Convert.ToDateTime(InnerRow["FECHAVENTA"]);

                        //Customer
                        if (!(InnerRow["NOMBRE"] is DBNull))
                        {
                            string  _customer = InnerRow["NOMBRE"].ToString();
                            contact contact   = ContactList.Where(x => x.name == _customer && x.id_company == id_company).FirstOrDefault();

                            if (contact != null)
                            {
                                sales_invoice.id_contact = contact.id_contact;
                                sales_invoice.contact    = contact;
                            }
                        }

                        //Condition (Cash or Credit)
                        if (!(InnerRow["TIPOVENTA"] is DBNull) && Convert.ToByte(InnerRow["TIPOVENTA"]) == 0)
                        {
                            sales_invoice.id_condition = app_conditionContado.id_condition;
                            //Contract...

                            app_contract_detail app_contract_detail =
                                db.app_contract_detail.Where(x => x.id_company == id_company &&
                                                             x.app_contract.id_condition == app_conditionContado.id_condition)
                                .FirstOrDefault();

                            if (app_contract_detail != null)
                            {
                                sales_invoice.app_contract = app_contract_detail.app_contract;
                                sales_invoice.id_contract  = app_contract_detail.id_contract;
                            }
                            else
                            {
                                app_contract app_contract = GenerateDefaultContrat(app_conditionContado, 0);
                                db.app_contract.Add(app_contract);
                                sales_invoice.app_contract = app_contract;
                                sales_invoice.id_contract  = app_contract.id_contract;
                            }
                        }
                        else if (!(InnerRow["TIPOVENTA"] is DBNull) && Convert.ToByte(InnerRow["TIPOVENTA"]) == 1)
                        {
                            sales_invoice.id_condition = app_conditionCrédito.id_condition;

                            //Contract...
                            if (!(InnerRow["FECHAVCTO"] is DBNull))
                            {
                                DateTime _due_date = Convert.ToDateTime(InnerRow["FECHAVCTO"]);
                                int      interval  = (_due_date - sales_invoice.trans_date).Days;

                                app_contract_detail app_contract_detail =
                                    db.app_contract_detail.Where(x =>
                                                                 x.app_contract.id_condition == sales_invoice.id_condition &&
                                                                 x.app_contract.id_company == id_company &&
                                                                 x.interval == interval).FirstOrDefault();

                                if (app_contract_detail != null)
                                {
                                    sales_invoice.app_contract = app_contract_detail.app_contract;
                                    sales_invoice.id_contract  = app_contract_detail.id_contract;
                                }
                                else
                                {
                                    app_contract app_contract = GenerateDefaultContrat(app_conditionCrédito, interval);
                                    db.app_contract.Add(app_contract);
                                    sales_invoice.app_contract = app_contract;
                                    sales_invoice.id_contract  = app_contract.id_contract;
                                }
                            }
                            else
                            {
                                if (db.app_contract.Where(x => x.name == "0 Días").Count() == 0)
                                {
                                    app_contract app_contract = GenerateDefaultContrat(app_conditionCrédito, 0);
                                    db.app_contract.Add(app_contract);
                                    sales_invoice.app_contract = app_contract;
                                    sales_invoice.id_contract  = app_contract.id_contract;
                                }
                                else
                                {
                                    app_contract app_contract = db.app_contract.Where(x => x.name == "0 Días").FirstOrDefault();
                                    sales_invoice.app_contract = app_contract;
                                    sales_invoice.id_contract  = app_contract.id_contract;
                                }
                            }
                        }
                        else
                        {
                            sales_invoice.id_condition = app_conditionContado.id_condition;

                            if (db.app_contract.Where(x => x.name == "0 Días").Count() == 0)
                            {
                                app_contract app_contract = GenerateDefaultContrat(app_conditionContado, 0);
                                db.app_contract.Add(app_contract);
                                sales_invoice.app_contract = app_contract;
                                sales_invoice.id_contract  = app_contract.id_contract;
                            }
                            else
                            {
                                app_contract app_contract = db.app_contract.Where(x => x.name == "0 Días").FirstOrDefault();
                                sales_invoice.app_contract = app_contract;
                                sales_invoice.id_contract  = app_contract.id_contract;
                            }
                        }

                        //Sales Rep
                        if (!(InnerRow["DESVENDEDOR"] is DBNull))
                        {
                            string    _sales_rep = InnerRow["DESVENDEDOR"].ToString();
                            sales_rep sales_rep  = sales_repList.Where(x => x.name == _sales_rep && x.id_company == id_company).FirstOrDefault();
                            sales_invoice.id_sales_rep = sales_rep.id_sales_rep;
                        }

                        int          id_location  = 0;
                        app_location app_location = null;

                        //Branch
                        if (!(InnerRow["DESSUCURSAL"] is DBNull))
                        {
                            //Branch
                            string     _branch    = InnerRow["DESSUCURSAL"].ToString();
                            app_branch app_branch = BranchList.Where(x => x.name == _branch && x.id_company == id_company).FirstOrDefault();
                            sales_invoice.id_branch = app_branch.id_branch;

                            //Location
                            if (LocationList.Where(x => x.id_branch == app_branch.id_branch && x.is_default).FirstOrDefault() != null)
                            {
                                id_location  = LocationList.Where(x => x.id_branch == app_branch.id_branch && x.is_default).FirstOrDefault().id_location;
                                app_location = LocationList.Where(x => x.id_branch == app_branch.id_branch && x.is_default).FirstOrDefault();
                            }


                            //Terminal
                            sales_invoice.id_terminal = TerminalList.Where(x => x.app_branch.id_branch == app_branch.id_branch).FirstOrDefault().id_terminal;
                        }


                        if (app_currencyfx != null)
                        {
                            sales_invoice.id_currencyfx  = app_currencyfx.id_currencyfx;
                            sales_invoice.app_currencyfx = app_currencyfx;
                        }

                        DataTable dt_CurrentDetail = new DataTable();
                        if (dt_detail.Select("CODVENTA =" + InnerRow[0].ToString()).Count() > 0)
                        {
                            dt_CurrentDetail = dt_detail.Select("CODVENTA =" + InnerRow[0].ToString()).CopyToDataTable();
                        }

                        foreach (DataRow row in dt_CurrentDetail.Rows)
                        {
                            //db Related Insertion.
                            sales_invoice_detail sales_invoice_detail = new sales_invoice_detail();

                            string _prod_Name = row["DESPRODUCTO"].ToString();
                            item   item       = ItemList.Where(x => x.name == _prod_Name && x.id_company == id_company).FirstOrDefault();
                            sales_invoice_detail.id_item  = item.id_item;
                            sales_invoice_detail.quantity = Convert.ToDecimal(row["CANTIDADVENTA"]);

                            sales_invoice_detail.id_location  = id_location;
                            sales_invoice_detail.app_location = app_location;

                            string _iva = row["IVA"].ToString();
                            if (_iva == "10.00")
                            {
                                if (app_vat_group10 != null)
                                {
                                    sales_invoice_detail.id_vat_group = app_vat_group10.id_vat_group;
                                }
                            }
                            else if (_iva == "5.00")
                            {
                                if (app_vat_group5 != null)
                                {
                                    sales_invoice_detail.id_vat_group = app_vat_group5.id_vat_group;
                                }
                            }
                            else
                            {
                                if (app_vat_group0 != null)
                                {
                                    sales_invoice_detail.id_vat_group = app_vat_group0.id_vat_group;
                                }
                            }

                            decimal cotiz1 = Convert.ToDecimal((row["COTIZACION1"] is DBNull) ? 1 : Convert.ToDecimal(row["COTIZACION1"]));
                            if (cotiz1 == 0)
                            {
                                cotiz1 = 1;
                            }
                            sales_invoice_detail.unit_price = (Convert.ToDecimal(row["PRECIOVENTANETO"]) / sales_invoice_detail.quantity) / cotiz1;
                            sales_invoice_detail.unit_cost  = Convert.ToDecimal(row["COSTOPROMEDIO"]);

                            //Commit Sales Invoice Detail
                            sales_invoice.sales_invoice_detail.Add(sales_invoice_detail);
                        }

                        if (sales_invoice.Error == null)
                        {
                            sales_invoice.State      = System.Data.Entity.EntityState.Added;
                            sales_invoice.IsSelected = true;
                            db.sales_invoice.Add(sales_invoice);

                            if (!(InnerRow["ESTADO"] is DBNull))
                            {
                                int status = Convert.ToInt32(InnerRow["ESTADO"]);

                                if (status == 0)
                                {
                                    sales_invoice.status = Status.Documents_General.Pending;
                                }
                                else if (status == 1)
                                {
                                    db.Approve(true);
                                    sales_invoice.State      = System.Data.Entity.EntityState.Modified;
                                    sales_invoice.status     = Status.Documents_General.Approved;
                                    sales_invoice.IsSelected = true;

                                    add_paymnet_detail(db, sales_invoice, InnerRow["SALDOCUOTA"], InnerRow["IMPORTE"]);
                                }
                                else if (status == 2)
                                {
                                    sales_invoice.status = Status.Documents_General.Annulled;

                                    if (!(InnerRow["MOTIVOANULADO"] is DBNull))
                                    {
                                        sales_invoice.comment = InnerRow["MOTIVOANULADO"].ToString();
                                    }
                                }

                                try
                                {
                                    db.SaveChanges();
                                    sales_invoice.IsSelected = false;
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }
                        }
                        else
                        {
                            //Add code to include error contacts into
                            SalesInvoice_ErrorList.Add(sales_invoice);
                        }
                        // }
                        value += 1;
                        Dispatcher.BeginInvoke((Action)(() => progSales.Value = value));
                        Dispatcher.BeginInvoke((Action)(() => salesValue.Text = value.ToString()));
                    }
                }


                FloorValue = RoofValue;
                RoofValue += 1000;
            }
        }
Esempio n. 26
0
        // GET: Contact/Edit/5
        public ActionResult Edit(int id)
        {
            contact e = es.GetContactByID(id);

            return(View(e));
        }
Esempio n. 27
0
        private void m_bwUpdateMasterDataContact_DoWork(object sender, DoWorkEventArgs e)
        {
            this.Invoke(new MethodInvoker(delegate
            {

                BrightPlatformEntities _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection);
                WaitDialog.Show("Processing import file...");
                this.SetEditableControlsContact(false);
                string[] _sRowValues = null;
                DataTable _dtContacts = m_dtImportFileMatchedContacts.Copy();

                /**
                 * clean records to be updated first. get all the new values from all cells and re-update each cell values
                 * with the new values from the import data as from the format (New Value/Old Value)
                 * _dtAccounts will now have the cleaned records
                 */
                #region Code Logic
                for (int i = 0; i < _dtContacts.Rows.Count; i++)
                {
                    foreach (DataColumn _dcItem in _dtContacts.Columns)
                    {
                        // get off inverted p on column values
                        _dtContacts.Rows[i][_dcItem.ColumnName] = _dtContacts.Rows[i][_dcItem.ColumnName].ToString().Replace("¶", "");

                        // we bypass non needed columns
                        //if (_dcItem.ColumnName.Equals("org_no") || _dcItem.ColumnName.Equals("action_type") || _dcItem.ColumnName.Equals("list_id") || _dcItem.ColumnName.Equals("account_idid"))
                        if (_dcItem.ColumnName.Equals("action_type") || _dcItem.ColumnName.Equals("list_id") || _dcItem.ColumnName.Equals("id"))
                            continue;

                        // we bypass "No Changes" rows
                        else if (_dtContacts.Rows[i]["action_type"].Equals("No Changes"))
                            continue;

                        // we bypass null/empty cell values
                        else if (string.IsNullOrEmpty(_dtContacts.Rows[i][_dcItem.ColumnName].ToString()))
                            continue;

                        // we bypass rows with no new values
                        // respectively, we dont update cell values that include separator "/" at index 0
                        else if (_dtContacts.Rows[i][_dcItem.ColumnName].ToString().IndexOf("[«]") < 1)
                            continue;

                        try
                        {
                            _sRowValues = null;
                            _sRowValues = _dtContacts.Rows[i][_dcItem.ColumnName].ToString().Split(new string[] { "[«]" }, StringSplitOptions.None);
                            if (_sRowValues.Length > 1)
                                _dtContacts.Rows[i][_dcItem.ColumnName] = _sRowValues[0].ToString();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Bright Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.SetEditableControlsContact(true);
                            e.Cancel = true;
                            return;
                        }
                    }
                }
                #endregion

                /**
                 * gather to be updated account records.
                 */
                #region Code Logic
                int _ContactId = 0;
                contact _efeContact= new contact();
                List<contact> _lstUpdatedContacts = new List<contact>();
                foreach (DataRow _drRow in _dtContacts.Select("action_type = 'For Update'"))
                {
                    _efeContact = null;
                    _ContactId = Convert.ToInt32(_drRow["id"]);
                    _efeContact = _efDbModel.contacts.FirstOrDefault(i => i.id == _ContactId);

                    if (_dtContacts.Columns.Contains("first_name"))
                        _efeContact.first_name = string.IsNullOrEmpty(_drRow["first_name"].ToString())? string.Empty : _drRow["first_name"].ToString();
                    if (_dtContacts.Columns.Contains("middle_name"))
                        _efeContact.middle_name = string.IsNullOrEmpty(_drRow["middle_name"].ToString()) ? string.Empty : _drRow["middle_name"].ToString();
                    if (_dtContacts.Columns.Contains("last_name"))
                        _efeContact.last_name = string.IsNullOrEmpty(_drRow["last_name"].ToString()) ? string.Empty : _drRow["last_name"].ToString();
                    if (_dtContacts.Columns.Contains("direct_phone"))
                        _efeContact.direct_phone = string.IsNullOrEmpty(_drRow["direct_phone"].ToString()) ? string.Empty : _drRow["direct_phone"].ToString();
                    if (_dtContacts.Columns.Contains("mobile"))
                        _efeContact.mobile = string.IsNullOrEmpty(_drRow["mobile"].ToString()) ? string.Empty : _drRow["mobile"].ToString();
                    if (_dtContacts.Columns.Contains("email"))
                        _efeContact.email = string.IsNullOrEmpty(_drRow["email"].ToString()) ? string.Empty : _drRow["email"].ToString();
                    if (_dtContacts.Columns.Contains("title_id"))
                        _efeContact.title_id = string.IsNullOrEmpty(_drRow["title_id"].ToString()) ? null : this.TryParseInt(_drRow["title_id"].ToString());
                    if (_dtContacts.Columns.Contains("title"))
                        _efeContact.title = string.IsNullOrEmpty(_drRow["title"].ToString()) ? string.Empty : _drRow["title"].ToString();
                    if (_dtContacts.Columns.Contains("role_tag_ids"))
                        _efeContact.role_tag_ids = string.IsNullOrEmpty(_drRow["role_tag_ids"].ToString()) ? null : _drRow["role_tag_ids"].ToString();
                    if (_dtContacts.Columns.Contains("address_1"))
                        _efeContact.address_1 = string.IsNullOrEmpty(_drRow["address_1"].ToString()) ? string.Empty : _drRow["address_1"].ToString();
                    if (_dtContacts.Columns.Contains("address_2"))
                        _efeContact.address_2 = string.IsNullOrEmpty(_drRow["address_2"].ToString()) ? string.Empty : _drRow["address_2"].ToString();
                    if (_dtContacts.Columns.Contains("city"))
                        _efeContact.city = string.IsNullOrEmpty(_drRow["city"].ToString()) ? string.Empty : _drRow["city"].ToString();
                    if (_dtContacts.Columns.Contains("zipcode"))
                        _efeContact.zipcode = string.IsNullOrEmpty(_drRow["zipcode"].ToString()) ? string.Empty : _drRow["zipcode"].ToString();
                    if (_dtContacts.Columns.Contains("country"))
                        _efeContact.country = string.IsNullOrEmpty(_drRow["country"].ToString()) ? string.Empty : _drRow["country"].ToString();
                    if (_dtContacts.Columns.Contains("remarks"))
                        _efeContact.remarks = string.IsNullOrEmpty(_drRow["remarks"].ToString()) ? string.Empty : _drRow["first_remarksname"].ToString();
                    if (_dtContacts.Columns.Contains("role"))
                        _efeContact.role = string.IsNullOrEmpty(_drRow["role"].ToString()) ? string.Empty : _drRow["role"].ToString();
                    if (_dtContacts.Columns.Contains("active"))
                        _efeContact.active = string.IsNullOrEmpty(_drRow["active"].ToString()) ? false : Convert.ToBoolean(this.TryParseByte(_drRow["active"].ToString()));

                    _efeContact.modified_by = UserSession.CurrentUser.UserId;
                    _efeContact.modified_date = DateTime.Now;
                    _efeContact.last_modified_machine = UserSession.CurrentUser.ComputerName;
                    _efeContact.last_modified_source = BrightVision.EventLog.Business.FacadeEventLog.Source_Bright_Manager_Master_Data_Import;

                    _lstUpdatedContacts.Add(_efeContact);
                }
                #endregion

                /**
                 * gather to be added account records.
                 */
                #region Code Logic
                DataTable _dtNewContacts = DataImportUtility.CreateContactTable();
                foreach (DataRow _drRow in _dtContacts.Select("action_type = 'New Record'"))
                {
                    DataRow _drNewContact = _dtContacts.NewRow();
                    foreach (DataColumn _dcContact in _dtContacts.Columns)
                    {
                        if (!_dtContacts.Columns.Contains(_dcContact.ColumnName))
                            continue;

                        if (_dcContact.DataType.FullName.Equals("System.String"))
                            _drNewContact[_dcContact.ColumnName] = _drRow[_dcContact.ColumnName].ToString();

                        else if (_dcContact.DataType.FullName.Equals("System.Decimal"))
                            _drNewContact[_dcContact.ColumnName] = this.TryParseDecimal(_drRow[_dcContact.ColumnName].ToString());

                        else if (_dcContact.DataType.FullName.Equals("System.Int32"))
                            _drNewContact[_dcContact.ColumnName] = this.TryParseInt(_drRow[_dcContact.ColumnName].ToString());

                        else if (_dcContact.DataType.FullName.Equals("System.Byte"))
                            _drNewContact[_dcContact.ColumnName] = this.TryParseByte(_drRow[_dcContact.ColumnName].ToString());
                    }

                    _drNewContact["created_by"] = UserSession.CurrentUser.UserId;
                    _drNewContact["created_date"] = DateTime.Now;
                    _drNewContact["modified_by"] = UserSession.CurrentUser.UserId;
                    _drNewContact["modified_date"] = DateTime.Now;
                    _drNewContact["last_modified_machine"] = UserSession.CurrentUser.ComputerName;
                    _drNewContact["last_modified_source"] = BrightVision.EventLog.Business.FacadeEventLog.Source_Bright_Manager_Master_Data_Import;

                    if (_drNewContact != null)
                        _dtNewContacts.Rows.Add(_drNewContact);
                }
                #endregion

                /**
                 * start the insert/update transaction.
                 * updates will be first processed over new data.
                 */
                #region Code Logic
                SqlConnection _sqlConnection = new SqlConnection(UserSession.ProviderConnection);
                _sqlConnection.Open();
                SqlTransaction _sqlTransaction = _sqlConnection.BeginTransaction();
                using (TransactionScope _efDbTransaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() {
                    Timeout = TimeSpan.FromMinutes(120),
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                })) {
                    try {
                        /**
                         * start updating records.
                         * transaction will not be saved until _efDbModel.AcceptAllChanges() is called.
                         */
                        if (_lstUpdatedContacts.Count > 0) {
                            contact _item = null;
                            int _id = 0;
                            for (int x = 0; x < _lstUpdatedContacts.Count; x++) {
                                _id = _lstUpdatedContacts[x].id;
                                _item = _efDbModel.contacts.FirstOrDefault(i => i.id == _id);
                                _efDbModel.contacts.ApplyCurrentValues(_lstUpdatedContacts[x]);
                            }
                            _efDbModel.SaveChanges();
                        }
                        //ObjectContact.SaveContacts(_lstUpdatedContacts, _efDbModel);

                        /**
                         * process new records using bulk insert.
                         * commit and accept all changes to the database.
                         * to be updated records will be committed on _efDbModel.AcceptAllChanges() call.
                         */
                        if (_dtNewContacts.Rows.Count > 0)
                            DatabaseUtility.ExecuteBulkProcessing("vw_contacts", _dtNewContacts, _sqlConnection, _sqlTransaction);

                        /**
                         * commit only if has records to insert/update.
                         */
                        if (_dtNewContacts.Rows.Count > 0)
                            _sqlTransaction.Commit();

                        if (_lstUpdatedContacts.Count > 0) {
                            _efDbModel.AcceptAllChanges();
                            _efDbTransaction.Complete();
                        }

                        tbxImportFileContact.Text = "";
                        cboSheetNameContact.Properties.Items.Clear();
                        cboSheetNameContact.Text = "";
                        gcMatchedColumnContact.DataSource = null;
                        gcImportFileDataContact.DataSource = null;
                        lblRecordStatisticContact.Text = "          Number of Records: 0";
                        WaitDialog.Close();
                        MessageBox.Show("Successfully saved items to contacts master data.", "Bright Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        WaitDialog.Show("Initializing ...");
                    }
                    catch (Exception Ex) {
                        WaitDialog.Close();
                        MessageBox.Show(string.Format("Transaction rolled backed due to the ff:{0}{0}{1}", Environment.NewLine, Ex.Message), "Bright Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        WaitDialog.Show("Initializing ...");
                        _efDbTransaction.Dispose();
                        _sqlTransaction.Rollback();
                        _efDbModel = null;
                        _sqlConnection = null;
                        this.SetEditableControlsContact(true);
                        e.Cancel = true;
                        return;
                    }
                    finally {
                        _efDbTransaction.Dispose();
                        _efDbModel = null;
                        _sqlConnection = null;
                    }

                    WaitDialog.Close();
                }
                #endregion

                /**
                 * delete the temporary excel file created during the matching
                 */
                if (File.Exists(m_sFileNameContact))
                    File.Delete(m_sFileNameContact);

                this.SetEditableControlsContact(true);
                btnUpdateToGridContact.Enabled = false;
                btnUpdateToMasterDataTableContact.Enabled = false;
                WaitDialog.Close();

            }));

            e.Cancel = true;
        }
Esempio n. 28
0
 public void View(contact contact)
 {
     MessengerInstance.Send <ContactMessage>(new ContactMessage(contact));
     new ViewContact().Show();
 }
Esempio n. 29
0
 AssertEquals(contact.details.name, "Name Surname");
Esempio n. 30
0
        /// <summary>
        /// Create a new patron entity and associated contacts
        /// </summary>
        /// <param name="patronDetailsForm">The form containing the patron and contacts details</param>
        /// <returns>success, message</returns>
        private async Task <Tuple <bool, string> > createPatron(PatronDetailsForm patronDetailsForm)
        {
            bool success = true;

            patron p = new patron();

            p.identifier            = patronDetailsForm.PatronIdentifier;
            p.name                  = patronDetailsForm.PatronName;
            p.language              = languageCode.eng;
            p.associatedlocation    = new associatedlocation[1];
            p.associatedlocation[0] = new associatedlocation();
            p.associatedlocation[0].associationtype = locationAssociationType.Item03;
            p.associatedlocation[0].locationref     = new string[1];
            p.associatedlocation[0].locationref[0]  = "http://localhost:8080/TalisSOA-2.1.0-SNAPSHOT/protocols/lcf/1.0/locations/GA";

            Tuple <bool, object, string> ret = await lcfEntityRequestAsync(rootURI + "patrons", typeof(patron), entityOperation.POST, p);

            if (!ret.Item1)
            {
                return(new Tuple <bool, string>(false, String.Format("Problem creating patron '{0}' - {1}", p.identifier, ret.Item3)));
            }

            var newPatron            = ret.Item2 as patron;
            var newPatronLocationUri = ret.Item3;

            // create contacts
            if (newPatronLocationUri.Length != 0 &&
                (patronDetailsForm.PatronAddress.Length != 0 ||
                 patronDetailsForm.PatronBusinessPhone.Length != 0 ||
                 patronDetailsForm.PatronEmail.Length != 0 ||
                 patronDetailsForm.PatronHomePhone.Length != 0 ||
                 patronDetailsForm.PatronMobilePhone.Length != 0))
            {
                contact c;

                if (patronDetailsForm.PatronHomePhone.Length != 0)
                {
                    c                   = new contact();
                    c.patronref         = newPatronLocationUri;
                    c.locator           = new string[1];
                    c.locator[0]        = patronDetailsForm.PatronHomePhone;
                    c.communicationtype = communicationType.Item02;
                    ret                 = await lcfEntityRequestAsync(rootURI + "contacts", typeof(contact), entityOperation.POST, c);

                    success = ret.Item1;
                }

                if (success && patronDetailsForm.PatronBusinessPhone.Length != 0)
                {
                    c                   = new contact();
                    c.patronref         = newPatronLocationUri;
                    c.locator           = new string[1];
                    c.locator[0]        = patronDetailsForm.PatronBusinessPhone;
                    c.communicationtype = communicationType.Item03;
                    ret                 = await lcfEntityRequestAsync(rootURI + "contacts", typeof(contact), entityOperation.POST, c);

                    success = ret.Item1;
                }

                if (success && patronDetailsForm.PatronMobilePhone.Length != 0)
                {
                    c                   = new contact();
                    c.patronref         = newPatronLocationUri;
                    c.locator           = new string[1];
                    c.locator[0]        = patronDetailsForm.PatronMobilePhone;
                    c.communicationtype = communicationType.Item04;
                    ret                 = await lcfEntityRequestAsync(rootURI + "contacts", typeof(contact), entityOperation.POST, c);

                    success = ret.Item1;
                }

                if (success && patronDetailsForm.PatronOtherPhone.Length != 0)
                {
                    c                   = new contact();
                    c.patronref         = newPatronLocationUri;
                    c.locator           = new string[1];
                    c.locator[0]        = patronDetailsForm.PatronOtherPhone;
                    c.communicationtype = communicationType.Item01;
                    ret                 = await lcfEntityRequestAsync(rootURI + "contacts", typeof(contact), entityOperation.POST, c);

                    success = ret.Item1;
                }

                if (success && patronDetailsForm.PatronEmail.Length != 0)
                {
                    c                   = new contact();
                    c.patronref         = newPatronLocationUri;
                    c.locator           = new string[1];
                    c.locator[0]        = patronDetailsForm.PatronEmail;
                    c.communicationtype = communicationType.Item05;
                    ret                 = await lcfEntityRequestAsync(rootURI + "contacts", typeof(contact), entityOperation.POST, c);

                    success = ret.Item1;
                }

                if (success && patronDetailsForm.PatronAddress.Length != 0)
                {
                    c                   = new contact();
                    c.patronref         = newPatronLocationUri;
                    c.communicationtype = communicationType.Item06;
                    c.locator           = new string[patronDetailsForm.PatronAddress.Length];

                    for (int i = 0; i < patronDetailsForm.PatronAddress.Length; i++)
                    {
                        c.locator[i] = patronDetailsForm.PatronAddress[i];
                    }

                    ret = await lcfEntityRequestAsync(rootURI + "contacts", typeof(contact), entityOperation.POST, c);

                    success = ret.Item1;
                }

                if (!success)
                {
                    return(new Tuple <bool, string>(false, String.Format("Problem creating contact for patron '{0}' - {1}", p.identifier, ret.Item3)));
                }
            }

            return(new Tuple <bool, string>(true, String.Format("Patron '{0}' created", newPatron.identifier)));
        }
        public void test4AVS()
        {
            var authorization = new authorization();
            authorization.orderId = "4";
            authorization.amount = 0;
            authorization.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Bob Black";
            contact.addressLine1 = "4 Main St.";
            contact.city = "Laurel";
            contact.state = "MD";
            contact.zip = "20708";
            contact.country = countryTypeEnum.US;
            authorization.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.AX;
            card.number = "375001000000005";
            card.expDate = "0412";
            card.cardValidationNum = "758";
            authorization.card = card;

            var response = litle.Authorize(authorization);
            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("44444", response.authCode);
            Assert.AreEqual("12", response.fraudResult.avsResult);
        }
Esempio n. 32
0
        private void button2_Click(object sender, EventArgs e)
        {
            var customerId = (from c in dc.Customers // get the record from the db
                              where c.Id == Program.custId
                              select c).FirstOrDefault();

            if (customerId != null)
            {
                contact cont = new contact(); //create new customer contact record of family type
                cont.first_name = strFName.Text;
                cont.last_name  = strLName.Text;
                dc.contacts.InsertOnSubmit(cont);
                dc.SubmitChanges();

                phone ph = new phone(); //create new phone record
                if (phoneNumM.Text != "" && areaCodeM.Text != "")
                {
                    ph.phone_type = "נייד";
                    ph.area_code  = areaCodeM.Text;
                    ph.phone_num  = phoneNumM.Text;
                    dc.phones.InsertOnSubmit(ph);
                    //   dc.SubmitChanges();
                }

                dc.SubmitChanges();

                if (ph != null)
                {
                    contact_phone cph = new contact_phone();
                    cph.contact_id = cont.ID;
                    cph.phone_id   = ph.ID;
                    cph.status     = "פעיל";
                    cph.type       = ph.phone_type;
                    dc.contact_phones.InsertOnSubmit(cph);
                }


                dc.SubmitChanges();

                wh_address adr = new wh_address(); // new address record

                adr.city_name = cityName.Text;
                if (streetName.Text != "")
                {
                    adr.street_name = streetName.Text;
                }
                if (houseNum.Text != "")
                {
                    adr.house_num = int.Parse(houseNum.Text);
                }
                if (apartNum.Text != "")
                {
                    adr.appartment_num = int.Parse(apartNum.Text);
                }
                if (postCode.Text != "")
                {
                    adr.zip_code = postCode.Text;
                }
                dc.wh_addresses.InsertOnSubmit(adr);
                dc.SubmitChanges();

                contact_address contaddr = new contact_address();//new contact address record

                contaddr.contact_id = cont.ID;
                contaddr.address_id = adr.ID;
                contaddr.status     = "פעיל";
                dc.contact_addresses.InsertOnSubmit(contaddr);

                dc.SubmitChanges();

                customer_contact custcont = new customer_contact(); //add new contact to customer
                custcont.customer_id = Program.custId;
                custcont.contact_id  = cont.ID;
                custcont.type        = "מטפל ראשי";
                custcont.status      = "פעיל";
                dc.customer_contacts.InsertOnSubmit(custcont);
                dc.SubmitChanges();
            }
        }
        public void test6Auth()
        {
            var authorization = new authorization();
            authorization.orderId = "6";
            authorization.amount = 60060;
            authorization.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Joe Green";
            contact.addressLine1 = "6 Main St.";
            contact.city = "Derry";
            contact.state = "NH";
            contact.zip = "03038";
            contact.country = countryTypeEnum.US;
            authorization.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4457010100000008";
            card.expDate = "0612";
            card.cardValidationNum = "992";
            authorization.card = card;

            var response = litle.Authorize(authorization);
            Assert.AreEqual("110", response.response);
            Assert.AreEqual("Insufficient Funds", response.message);
            Assert.AreEqual("34", response.fraudResult.avsResult);
            Assert.AreEqual("P", response.fraudResult.cardValidationResult);
        }
        public void InvalidCredientialsBatch()
        {
            var litleBatchRequest = new batchRequest(memoryStreams);

            var authorization = new authorization();
            authorization.reportGroup = "Planets";
            authorization.orderId = "12344";
            authorization.amount = 106;
            authorization.orderSource = orderSourceType.ecommerce;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4100000000000001";
            card.expDate = "1210";
            authorization.card = card;

            litleBatchRequest.addAuthorization(authorization);

            var authorization2 = new authorization();
            authorization2.reportGroup = "Planets";
            authorization2.orderId = "12345";
            authorization2.amount = 106;
            authorization2.orderSource = orderSourceType.ecommerce;
            var card2 = new cardType();
            card2.type = methodOfPaymentTypeEnum.VI;
            card2.number = "4242424242424242";
            card2.expDate = "1210";
            authorization2.card = card2;

            litleBatchRequest.addAuthorization(authorization2);

            var reversal = new authReversal();
            reversal.litleTxnId = 12345678000L;
            reversal.amount = 106;
            reversal.payPalNotes = "Notes";

            litleBatchRequest.addAuthReversal(reversal);

            var reversal2 = new authReversal();
            reversal2.litleTxnId = 12345678900L;
            reversal2.amount = 106;
            reversal2.payPalNotes = "Notes";

            litleBatchRequest.addAuthReversal(reversal2);

            var capture = new capture();
            capture.litleTxnId = 123456000;
            capture.amount = 106;
            capture.payPalNotes = "Notes";

            litleBatchRequest.addCapture(capture);

            var capture2 = new capture();
            capture2.litleTxnId = 123456700;
            capture2.amount = 106;
            capture2.payPalNotes = "Notes";

            litleBatchRequest.addCapture(capture2);

            var capturegivenauth = new captureGivenAuth();
            capturegivenauth.amount = 106;
            capturegivenauth.orderId = "12344";
            var authInfo = new authInformation();
            var authDate = new DateTime(2002, 10, 9);
            authInfo.authDate = authDate;
            authInfo.authCode = "543216";
            authInfo.authAmount = 12345;
            capturegivenauth.authInformation = authInfo;
            capturegivenauth.orderSource = orderSourceType.ecommerce;
            capturegivenauth.card = card;

            litleBatchRequest.addCaptureGivenAuth(capturegivenauth);

            var capturegivenauth2 = new captureGivenAuth();
            capturegivenauth2.amount = 106;
            capturegivenauth2.orderId = "12344";
            var authInfo2 = new authInformation();
            authDate = new DateTime(2003, 10, 9);
            authInfo2.authDate = authDate;
            authInfo2.authCode = "543216";
            authInfo2.authAmount = 12345;
            capturegivenauth2.authInformation = authInfo;
            capturegivenauth2.orderSource = orderSourceType.ecommerce;
            capturegivenauth2.card = card2;

            litleBatchRequest.addCaptureGivenAuth(capturegivenauth2);

            var creditObj = new credit();
            creditObj.amount = 106;
            creditObj.orderId = "2111";
            creditObj.orderSource = orderSourceType.ecommerce;
            creditObj.card = card;

            litleBatchRequest.addCredit(creditObj);

            var creditObj2 = new credit();
            creditObj2.amount = 106;
            creditObj2.orderId = "2111";
            creditObj2.orderSource = orderSourceType.ecommerce;
            creditObj2.card = card2;

            litleBatchRequest.addCredit(creditObj2);

            var echeckcredit = new echeckCredit();
            echeckcredit.amount = 12L;
            echeckcredit.orderId = "12345";
            echeckcredit.orderSource = orderSourceType.ecommerce;
            var echeck = new echeckType();
            echeck.accType = echeckAccountTypeEnum.Checking;
            echeck.accNum = "1099999903";
            echeck.routingNum = "011201995";
            echeck.checkNum = "123455";
            echeckcredit.echeck = echeck;
            var billToAddress = new contact();
            billToAddress.name = "Bob";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "litle.com";
            echeckcredit.billToAddress = billToAddress;

            litleBatchRequest.addEcheckCredit(echeckcredit);

            var echeckcredit2 = new echeckCredit();
            echeckcredit2.amount = 12L;
            echeckcredit2.orderId = "12346";
            echeckcredit2.orderSource = orderSourceType.ecommerce;
            var echeck2 = new echeckType();
            echeck2.accType = echeckAccountTypeEnum.Checking;
            echeck2.accNum = "1099999903";
            echeck2.routingNum = "011201995";
            echeck2.checkNum = "123456";
            echeckcredit2.echeck = echeck2;
            var billToAddress2 = new contact();
            billToAddress2.name = "Mike";
            billToAddress2.city = "Lowell";
            billToAddress2.state = "MA";
            billToAddress2.email = "litle.com";
            echeckcredit2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckCredit(echeckcredit2);

            var echeckredeposit = new echeckRedeposit();
            echeckredeposit.litleTxnId = 123456;
            echeckredeposit.echeck = echeck;

            litleBatchRequest.addEcheckRedeposit(echeckredeposit);

            var echeckredeposit2 = new echeckRedeposit();
            echeckredeposit2.litleTxnId = 123457;
            echeckredeposit2.echeck = echeck2;

            litleBatchRequest.addEcheckRedeposit(echeckredeposit2);

            var echeckSaleObj = new echeckSale();
            echeckSaleObj.amount = 123456;
            echeckSaleObj.orderId = "12345";
            echeckSaleObj.orderSource = orderSourceType.ecommerce;
            echeckSaleObj.echeck = echeck;
            echeckSaleObj.billToAddress = billToAddress;

            litleBatchRequest.addEcheckSale(echeckSaleObj);

            var echeckSaleObj2 = new echeckSale();
            echeckSaleObj2.amount = 123456;
            echeckSaleObj2.orderId = "12346";
            echeckSaleObj2.orderSource = orderSourceType.ecommerce;
            echeckSaleObj2.echeck = echeck2;
            echeckSaleObj2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckSale(echeckSaleObj2);

            var echeckVerificationObject = new echeckVerification();
            echeckVerificationObject.amount = 123456;
            echeckVerificationObject.orderId = "12345";
            echeckVerificationObject.orderSource = orderSourceType.ecommerce;
            echeckVerificationObject.echeck = echeck;
            echeckVerificationObject.billToAddress = billToAddress;

            litleBatchRequest.addEcheckVerification(echeckVerificationObject);

            var echeckVerificationObject2 = new echeckVerification();
            echeckVerificationObject2.amount = 123456;
            echeckVerificationObject2.orderId = "12346";
            echeckVerificationObject2.orderSource = orderSourceType.ecommerce;
            echeckVerificationObject2.echeck = echeck2;
            echeckVerificationObject2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckVerification(echeckVerificationObject2);

            var forcecapture = new forceCapture();
            forcecapture.amount = 106;
            forcecapture.orderId = "12344";
            forcecapture.orderSource = orderSourceType.ecommerce;
            forcecapture.card = card;

            litleBatchRequest.addForceCapture(forcecapture);

            var forcecapture2 = new forceCapture();
            forcecapture2.amount = 106;
            forcecapture2.orderId = "12345";
            forcecapture2.orderSource = orderSourceType.ecommerce;
            forcecapture2.card = card2;

            litleBatchRequest.addForceCapture(forcecapture2);

            var saleObj = new sale();
            saleObj.amount = 106;
            saleObj.litleTxnId = 123456;
            saleObj.orderId = "12344";
            saleObj.orderSource = orderSourceType.ecommerce;
            saleObj.card = card;

            litleBatchRequest.addSale(saleObj);

            var saleObj2 = new sale();
            saleObj2.amount = 106;
            saleObj2.litleTxnId = 123456;
            saleObj2.orderId = "12345";
            saleObj2.orderSource = orderSourceType.ecommerce;
            saleObj2.card = card2;

            litleBatchRequest.addSale(saleObj2);

            var registerTokenRequest = new registerTokenRequestType();
            registerTokenRequest.orderId = "12344";
            registerTokenRequest.accountNumber = "1233456789103801";
            registerTokenRequest.reportGroup = "Planets";

            litleBatchRequest.addRegisterTokenRequest(registerTokenRequest);

            var registerTokenRequest2 = new registerTokenRequestType();
            registerTokenRequest2.orderId = "12345";
            registerTokenRequest2.accountNumber = "1233456789103801";
            registerTokenRequest2.reportGroup = "Planets";

            litleBatchRequest.addRegisterTokenRequest(registerTokenRequest2);

            litle.addBatch(litleBatchRequest);

            try
            {
                var litleResponse = litle.sendToLitleWithStream();
            }
            catch (LitleOnlineException e)
            {
                Assert.AreEqual("Error establishing a network connection", e.Message);
            }
        }
        public void test7Sale()
        {
            var sale = new sale();
            sale.orderId = "7";
            sale.amount = 70070;
            sale.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Jane Murray";
            contact.addressLine1 = "7 Main St.";
            contact.city = "Amesbury";
            contact.state = "MA";
            contact.zip = "01913";
            contact.country = countryTypeEnum.US;
            sale.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.MC;
            card.number = "5112010100000002";
            card.expDate = "0712";
            card.cardValidationNum = "251";
            sale.card = card;

            var response = litle.Sale(sale);
            Assert.AreEqual("301", response.response);
            Assert.AreEqual("Invalid Account Number", response.message);
            Assert.AreEqual("34", response.fraudResult.avsResult);
            Assert.AreEqual("N", response.fraudResult.cardValidationResult);
        }
        public void EcheckPreNoteTestAll()
        {
            var litleBatchRequest = new batchRequest(memoryStreams);

            var billToAddress = new contact();
            billToAddress.name = "Mike";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "litle.com";

            var echeckSuccess = new echeckType();
            echeckSuccess.accType = echeckAccountTypeEnum.Corporate;
            echeckSuccess.accNum = "1092969901";
            echeckSuccess.routingNum = "011075150";
            echeckSuccess.checkNum = "123456";

            var echeckRoutErr = new echeckType();
            echeckRoutErr.accType = echeckAccountTypeEnum.Checking;
            echeckRoutErr.accNum = "6099999992";
            echeckRoutErr.routingNum = "053133052";
            echeckRoutErr.checkNum = "123457";

            var echeckAccErr = new echeckType();
            echeckAccErr.accType = echeckAccountTypeEnum.Corporate;
            echeckAccErr.accNum = "10@2969901";
            echeckAccErr.routingNum = "011100012";
            echeckAccErr.checkNum = "123458";

            var echeckPreNoteSaleSuccess = new echeckPreNoteSale();
            echeckPreNoteSaleSuccess.orderId = "000";
            echeckPreNoteSaleSuccess.orderSource = orderSourceType.ecommerce;
            echeckPreNoteSaleSuccess.echeck = echeckSuccess;
            echeckPreNoteSaleSuccess.billToAddress = billToAddress;
            litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleSuccess);

            var echeckPreNoteSaleRoutErr = new echeckPreNoteSale();
            echeckPreNoteSaleRoutErr.orderId = "900";
            echeckPreNoteSaleRoutErr.orderSource = orderSourceType.ecommerce;
            echeckPreNoteSaleRoutErr.echeck = echeckRoutErr;
            echeckPreNoteSaleRoutErr.billToAddress = billToAddress;
            litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleRoutErr);

            var echeckPreNoteSaleAccErr = new echeckPreNoteSale();
            echeckPreNoteSaleAccErr.orderId = "301";
            echeckPreNoteSaleAccErr.orderSource = orderSourceType.ecommerce;
            echeckPreNoteSaleAccErr.echeck = echeckAccErr;
            echeckPreNoteSaleAccErr.billToAddress = billToAddress;
            litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleAccErr);

            var echeckPreNoteCreditSuccess = new echeckPreNoteCredit();
            echeckPreNoteCreditSuccess.orderId = "000";
            echeckPreNoteCreditSuccess.orderSource = orderSourceType.ecommerce;
            echeckPreNoteCreditSuccess.echeck = echeckSuccess;
            echeckPreNoteCreditSuccess.billToAddress = billToAddress;
            litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditSuccess);

            var echeckPreNoteCreditRoutErr = new echeckPreNoteCredit();
            echeckPreNoteCreditRoutErr.orderId = "900";
            echeckPreNoteCreditRoutErr.orderSource = orderSourceType.ecommerce;
            echeckPreNoteCreditRoutErr.echeck = echeckRoutErr;
            echeckPreNoteCreditRoutErr.billToAddress = billToAddress;
            litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditRoutErr);

            var echeckPreNoteCreditAccErr = new echeckPreNoteCredit();
            echeckPreNoteCreditAccErr.orderId = "301";
            echeckPreNoteCreditAccErr.orderSource = orderSourceType.ecommerce;
            echeckPreNoteCreditAccErr.echeck = echeckAccErr;
            echeckPreNoteCreditAccErr.billToAddress = billToAddress;
            litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditAccErr);

            litle.addBatch(litleBatchRequest);

            var litleResponse = litle.sendToLitleWithStream();

            Assert.NotNull(litleResponse);
            Assert.AreEqual("0", litleResponse.response);
            Assert.AreEqual("Valid Format", litleResponse.message);

            var litleBatchResponse = litleResponse.nextBatchResponse();
            while (litleBatchResponse != null)
            {
                var echeckPreNoteSaleResponse = litleBatchResponse.nextEcheckPreNoteSaleResponse();
                while (echeckPreNoteSaleResponse != null)
                {
                    Assert.AreEqual(echeckPreNoteSaleResponse.orderId, echeckPreNoteSaleResponse.response);

                    echeckPreNoteSaleResponse = litleBatchResponse.nextEcheckPreNoteSaleResponse();
                }

                var echeckPreNoteCreditResponse = litleBatchResponse.nextEcheckPreNoteCreditResponse();
                while (echeckPreNoteCreditResponse != null)
                {
                    Assert.AreEqual(echeckPreNoteCreditResponse.orderId, echeckPreNoteCreditResponse.response);

                    echeckPreNoteCreditResponse = litleBatchResponse.nextEcheckPreNoteCreditResponse();
                }

                litleBatchResponse = litleResponse.nextBatchResponse();
            }
        }
        public void test9AVS()
        {
            var authorization = new authorization();
            authorization.orderId = "9";
            authorization.amount = 0;
            authorization.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "James Miller";
            contact.addressLine1 = "9 Main St.";
            contact.city = "Boston";
            contact.state = "MA";
            contact.zip = "02134";
            contact.country = countryTypeEnum.US;
            authorization.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.AX;
            card.number = "375001010000003";
            card.expDate = "0912";
            card.cardValidationNum = "0421";
            authorization.card = card;

            var response = litle.Authorize(authorization);
            Assert.AreEqual("303", response.response);
            Assert.AreEqual("Pick Up Card", response.message);
            Assert.AreEqual("34", response.fraudResult.avsResult);
        }
Esempio n. 38
0
        public contact GetContact(int ID)
        {
            contact contact = dbConnection.contacts.SingleOrDefault(u => u.ID == ID);

            return(contact);
        }
Esempio n. 39
0
        public void Test2Auth()
        {
            var authorization = new authorization();

            authorization.id          = "1";
            authorization.orderId     = "2";
            authorization.amount      = 20020;
            authorization.orderSource = orderSourceType.ecommerce;
            var contact = new contact();

            contact.name                = "Mike J. Hammer";
            contact.addressLine1        = "2 Main St.";
            contact.addressLine2        = "Apt. 222";
            contact.city                = "Riverside";
            contact.state               = "RI";
            contact.zip                 = "02915";
            contact.country             = countryTypeEnum.US;
            authorization.billToAddress = contact;
            var card = new cardType();

            card.type              = methodOfPaymentTypeEnum.MC;
            card.number            = "5112010000000003";
            card.expDate           = "0212";
            card.cardValidationNum = "261";
            authorization.card     = card;
            var authenticationvalue = new fraudCheckType();

            authenticationvalue.authenticationValue = "BwABBJQ1AgAAAAAgJDUCAAAAAAA=";
            authorization.cardholderAuthentication  = authenticationvalue;

            var response = this.SendTransaction <authorizationResponse>(authorization);

            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("22222", response.authCode.Trim());
            Assert.AreEqual("10", response.fraudResult.avsResult);
            Assert.AreEqual("M", response.fraudResult.cardValidationResult);

            var capture = new capture();

            capture.id       = response.id;
            capture.cnpTxnId = response.cnpTxnId;
            var captureresponse = this.SendTransaction <captureResponse>(capture);

            Assert.AreEqual("000", captureresponse.response);
            Assert.AreEqual("Approved", captureresponse.message);

            var credit = new credit();

            credit.id       = captureresponse.id;
            credit.cnpTxnId = captureresponse.cnpTxnId;
            var creditResponse = this.SendTransaction <creditResponse>(credit);

            Assert.AreEqual("000", creditResponse.response);
            Assert.AreEqual("Approved", creditResponse.message);

            var newvoid = new voidTxn();

            newvoid.id       = creditResponse.id;
            newvoid.cnpTxnId = creditResponse.cnpTxnId;
            var voidResponse = this.SendTransaction <voidResponse>(newvoid);

            Assert.AreEqual("000", voidResponse.response);
            Assert.AreEqual("Approved", voidResponse.message);
        }
Esempio n. 40
0
        public ActionResult Subscribe(TestProject.Models.Subscribe subscribe, string confirmKey)
        {
            ChargifyConnect chargify = ChargifyTools.Chargify;
            string          plan     = subscribe.plan;
            bool            isCredit = subscribe.hasCreditCard || subscribe.creditcard.requireCredit;//ChargifyTools.RequireCreditCard(subscribe.plan);

            try
            {
                if (ChargifyTools.IsChargifyProduct(subscribe.plan))
                {
                    ViewBag.confirmKey = confirmKey;
                    ViewBag.plan       = subscribe.plan;
                    if (ValidatePassword(subscribe.password) == false)
                    {
                        //ViewBag.contactGenderId = new SelectList(db.contactGender.ToList(), "contactGenderId", "name");
                        ViewBag.Message = "Error password, you need a format that contains capital letters and numbers, example: Michael7.";
                        ViewBag.plan    = subscribe.plan;

                        return(View(subscribe));
                    }

                    userLogin user = new userLogin();
                    contact   cont = new contact();
                    tenant    tnt  = new tenant();
                    //----------------------------------------------------------------------------------------------------------------
                    //----------------------------------------------------------------------------------------------------------------
                    //----------------------------------------------------------------------------------------------------------------

                    tnt.tenantSubscriptionPlanId = (from pl in db.tenantSubscriptionPlan
                                                    where pl.code.ToLower().Equals(plan.ToLower())
                                                    select pl.tenantSubscriptionPlanId).FirstOrDefault();
                    tnt.active           = true;
                    tnt.allocatedUsers   = 1; //cantidad de usuarios asignados
                    tnt.billingRefNumber = Guid.NewGuid().ToString();
                    tnt.companyName      = subscribe.company;
                    tnt.companyURL       = "N/A";
                    tnt.database         = "TestProject";
                    tnt.tenantStatusId   = 2;
                    tnt.tenantSourceId   = 2;
                    if (isCredit)
                    {
                        tnt.tenentBillingTypeId = 1;
                    }
                    else
                    {
                        tnt.tenentBillingTypeId = 2;
                    }

                    /****** Valores quemados de campos auditoria*****/
                    tnt.updatedById    = 0;
                    tnt.createdById    = TntIdTestProject; // Id tenant TestProject
                    tnt.modifyDateTime = new DateTime(1900, 1, 1, 0, 0, 0);
                    tnt.insertDateTime = DateTime.Now;
                    /****** Valores quemados de campos auditoria*****/

                    db.tenant.Add(tnt);
                    db.SaveChanges();



                    var city = db.genCity
                               .Include(x => x.genState.genContry)
                               .SingleOrDefault(x => x.genCityId == Convert.ToInt32(subscribe.genCityId));
                    if (isCredit)
                    {
                        contactPhone phone = new contactPhone
                        {
                            active             = true,
                            number             = subscribe.phoneNumber,
                            contactId          = cont.contactId,
                            contactPhoneTypeId = 1,
                            tenantId           = tnt.tenantId,
                            updatedById        = 0,
                            createdById        = TntIdTestProject, // Id tenant TestProject
                            modifyDateTime     = new DateTime(1900, 1, 1, 0, 0, 0),
                            insertDateTime     = DateTime.Now
                        };

                        db.contactPhone.Add(phone);
                        db.SaveChanges();

                        cont.preferredBillAddressId = address.contactAddressId;
                        cont.preferredPhoneId       = phone.contactPhoneId;
                        db.Entry(cont).State        = EntityState.Modified;
                        db.SaveChanges();
                    }



                    /*** cosas de chargify!!!*/
                    CustomerAttributes customerInformation = new CustomerAttributes();
                    customerInformation.FirstName    = subscribe.firstName;
                    customerInformation.LastName     = subscribe.lastName;
                    customerInformation.Organization = subscribe.company;
                    customerInformation.Email        = subscribe.email;
                    // Create a new guid, this would be the Membership UserID if we were creating a new user simultaneously
                    customerInformation.SystemID = tnt.billingRefNumber;


                    ISubscription newSubscription = null;
                    string        productHandle   = plan;

                    if (isCredit)
                    {
                        CreditCardAttributes creditCardInfo = new CreditCardAttributes();

                        creditCardInfo.FullNumber      = subscribe.creditcard.creditCardNumber;
                        creditCardInfo.CVV             = subscribe.creditcard.cvv;
                        creditCardInfo.ExpirationMonth = subscribe.creditcard.ExpireMonth;
                        creditCardInfo.ExpirationYear  = subscribe.creditcard.ExpireYear;

                        creditCardInfo.BillingAddress = subscribe.street;
                        creditCardInfo.BillingCity    = city.City;//subscribe.city;
                        creditCardInfo.BillingState   = city.genState.State;
                        creditCardInfo.BillingZip     = subscribe.postalCode;
                        creditCardInfo.BillingCountry = city.genState.genContry.contry;

                        newSubscription = chargify.CreateSubscription(productHandle, customerInformation, creditCardInfo);
                    }
                    else
                    {
                        newSubscription = chargify.CreateSubscription(productHandle, customerInformation);
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                       eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                           ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (Exception e)
            {
                return(View(subscribe));
            }


            return(View(subscribe));
        }
Esempio n. 41
0
        public void purchase()
        {
            string sql = " SELECT " +
            " COMPRAS.CODCOMPRA, " +        //0
            " COMPRAS.NUMCOMPRA, " +        //1
            " COMPRAS.FECHACOMPRA, " +      //2
            " COMPRAS.TOTALDESCUENTO, " +   //3
            " COMPRAS.TOTALEXENTA, " +      //4
            " COMPRAS.TOTALGRAVADA, " +     //5
            " COMPRAS.TOTALIVA, " +         //6
            " COMPRAS.MODALIDADPAGO, " +    //7
            " COMPRAS.FECGRA, " +           //8
            " COMPRAS.ESTADO, " +           //9
            " COMPRAS.MOTIVOANULADO, " +    //10
            " COMPRAS.FECHACOMPRA, " +      //11
            " COMPRAS.TIMBRADOPROV, " +     //12
            " COMPRAS.TOTALIVA5, " +        //13
            " COMPRAS.TOTALIVA10, " +       //14
            " COMPRAS.METODO, " +           //15
            " COMPRAS.TOTALGRAVADO5, " +    //16
            " COMPRAS.TOTALGRAVADO10, " +   //17
            " COMPRAS.ASENTADO, " +         //18
            " COMPRAS.TOTALCOMPRA, " +      //19
            " PROVEEDOR.NOMBRE, " +         //20
            " PROVEEDOR.RUC_CIN, " +        //21
            " dbo.SUCURSAL.DESSUCURSAL, " +//28
            " COMPRAS.COTIZACION1, " +
            " dbo.FACTURAPAGAR.FECHAVCTO" +
            " FROM  COMPRAS RIGHT OUTER JOIN " +
            " PROVEEDOR ON COMPRAS.CODPROVEEDOR = PROVEEDOR.CODPROVEEDOR" +
            " LEFT OUTER JOIN FACTURAPAGAR ON COMPRAS.CODCOMPRA = FACTURAPAGAR.CODCOMPRA" +
             " RIGHT OUTER JOIN SUCURSAL ON COMPRAS.CODSUCURSAL = SUCURSAL.CODSUCURSAL";

            SqlConnection conn = new SqlConnection(_connString);

            //Counts Total number of Rows we have to process
            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            cmd.CommandText = "SELECT COUNT(*) FROM COMPRAS";
            cmd.CommandType = CommandType.Text;
            int count = (int)cmd.ExecuteScalar();
            conn.Close();

            int value = 0;

            Dispatcher.BeginInvoke((Action)(() => purchaseMaximum.Text = count.ToString()));
            Dispatcher.BeginInvoke((Action)(() => purchaseValue.Text = value.ToString()));
            Dispatcher.BeginInvoke((Action)(() => progPurchase.Maximum = count));
            Dispatcher.BeginInvoke((Action)(() => progPurchase.Value = value));

            cmd = new SqlCommand(sql, conn);
            conn.Open();
            cmd.CommandType = CommandType.Text;
            DataTable dt_purchase = exeDT(sql);
            //SqlDataReader reader = cmd.ExecuteReader();

            foreach (DataRow purchaserow in dt_purchase.Rows)
            {
                using (PurchaseInvoiceDB db = new PurchaseInvoiceDB())
                {
                    db.Configuration.AutoDetectChangesEnabled = false;

                    purchase_invoice purchase_invoice = db.New();

                    purchase_invoice.number = purchaserow["NUMCOMPRA"] is DBNull ? null : purchaserow["NUMCOMPRA"].ToString();
                    if (!(purchaserow["FECHACOMPRA"] is DBNull))
                    {
                        purchase_invoice.trans_date = Convert.ToDateTime(purchaserow["FECHACOMPRA"]);
                    }
                    else
                    {
                        continue;
                    }

                    //Supplier
                    if (!(purchaserow["NOMBRE"] is DBNull))
                    {
                        string _customer = purchaserow["NOMBRE"].ToString();
                        contact contact = db.contacts.Where(x => x.name == _customer && x.id_company == id_company).FirstOrDefault();
                        purchase_invoice.id_contact = contact.id_contact;
                    }

                    //Condition (Cash or Credit)
                    if (!(purchaserow["MODALIDADPAGO"] is DBNull) && Convert.ToInt32(purchaserow["MODALIDADPAGO"]) == 0)
                    {
                        app_condition app_condition = db.app_condition.Where(x => x.name == "Contado").FirstOrDefault();
                        purchase_invoice.id_condition = app_condition.id_condition;
                        //Contract...

                        app_contract_detail app_contract_detail = db.app_contract_detail.Where(x => x.app_contract.id_condition == purchase_invoice.id_condition && x.app_contract.id_company == id_company).FirstOrDefault();
                        if (app_contract_detail != null)
                        {
                            purchase_invoice.id_contract = app_contract_detail.id_contract;
                        }
                        else
                        {
                            app_contract app_contract = GenerateDefaultContrat(app_condition, 0);
                            db.app_contract.Add(app_contract);

                            purchase_invoice.app_contract = app_contract;
                            purchase_invoice.id_contract = app_contract.id_contract;
                        }
                    }
                    else if (!(purchaserow["MODALIDADPAGO"] is DBNull) && Convert.ToInt32(purchaserow["MODALIDADPAGO"]) == 1)
                    {
                        app_condition app_condition = db.app_condition.Where(x => x.name == "Crédito" && x.id_company == id_company).FirstOrDefault();
                        purchase_invoice.id_condition = app_condition.id_condition;
                        //Contract...
                        if (!(purchaserow["FECHAVCTO"] is DBNull))
                        {
                            DateTime _due_date = Convert.ToDateTime(purchaserow["FECHAVCTO"]);
                            int interval = (_due_date - purchase_invoice.trans_date).Days;
                            app_contract_detail app_contract_detail = db.app_contract_detail.Where(x => x.app_contract.id_condition == purchase_invoice.id_condition && x.app_contract.id_company == id_company && x.interval == interval).FirstOrDefault();
                            if (app_contract_detail != null)
                            {
                                purchase_invoice.id_contract = app_contract_detail.id_contract;
                            }
                            else
                            {
                                app_contract app_contract = GenerateDefaultContrat(app_condition, interval);
                                db.app_contract.Add(app_contract);

                                purchase_invoice.app_contract = app_contract;
                                purchase_invoice.id_contract = app_contract.id_contract;
                            }
                        }
                    }

                    int id_location = 0;
                    //Branch
                    if (!(purchaserow["DESSUCURSAL"] is DBNull))
                    {
                        //Branch
                        string _branch = purchaserow["DESSUCURSAL"].ToString();
                        app_branch app_branch = db.app_branch.Where(x => x.name == _branch && x.id_company == id_company).FirstOrDefault();
                        purchase_invoice.id_branch = app_branch.id_branch;

                        //Location
                        id_location = db.app_location.Where(x => x.id_branch == app_branch.id_branch && x.is_default).FirstOrDefault().id_location;

                        //Terminal
                        purchase_invoice.id_terminal = db.app_terminal.Where(x => x.app_branch.id_branch == app_branch.id_branch).FirstOrDefault().id_terminal;
                    }

                    string _desMoneda = string.Empty;

                    //Sales Invoice Detail
                    string sqlDetail = "SELECT"
                    + " dbo.PRODUCTOS.DESPRODUCTO as ITEM_DESPRODUCTO," //0
                    + " dbo.COMPRASDETALLE.DESPRODUCTO," //1
                    + " dbo.COMPRASDETALLE.CANTIDADCOMPRA, " //2
                    + " dbo.COMPRASDETALLE.COSTOUNITARIO, " //3
                    + " dbo.COMPRASDETALLE.IVA, " //4
                    + " dbo.COMPRAS.COTIZACION1, " //5
                    + " dbo.MONEDA.DESMONEDA " //6
                    + " FROM dbo.COMPRAS LEFT OUTER JOIN"
                    + " dbo.MONEDA ON dbo.COMPRAS.CODMONEDA = dbo.MONEDA.CODMONEDA LEFT OUTER JOIN"
                    + " dbo.COMPRASDETALLE ON dbo.COMPRAS.CODCOMPRA = dbo.COMPRASDETALLE.CODCOMPRA LEFT OUTER JOIN"
                    + " dbo.PRODUCTOS ON dbo.COMPRASDETALLE.CODPRODUCTO = dbo.PRODUCTOS.CODPRODUCTO"
                    + " WHERE (dbo.COMPRASDETALLE.CODCOMPRA = " + purchaserow["CODCOMPRA"].ToString() + ")";

                    DataTable dt = exeDT(sqlDetail);
                    foreach (DataRow row in dt.Rows)
                    {
                        //db Related Insertion.
                        purchase_invoice.id_currencyfx = 1;

                        purchase_invoice_detail purchase_invoice_detail = new purchase_invoice_detail();

                        string _prod_Name = row["ITEM_DESPRODUCTO"].ToString();
                        if (db.items.Where(x => x.name == _prod_Name && x.id_company == id_company).FirstOrDefault() != null)
                        {
                            //Only if Item Exists
                            item item = db.items.Where(x => x.name == _prod_Name && x.id_company == id_company).FirstOrDefault();
                            purchase_invoice_detail.id_item = item.id_item;
                        }

                        if (row["DESPRODUCTO"] is DBNull)
                        {
                            //If not Item Description, then just continue out of this loop.
                            continue;
                        }

                        purchase_invoice_detail.item_description = row["DESPRODUCTO"].ToString();
                        purchase_invoice_detail.quantity = Convert.ToDecimal(row["CANTIDADCOMPRA"]);

                        purchase_invoice_detail.id_location = id_location;

                        string _iva = row["IVA"].ToString();
                        if (_iva == "10.00")
                        {
                            purchase_invoice_detail.id_vat_group = db.app_vat_group.Where(x => x.name == "10%").FirstOrDefault().id_vat_group;
                        }
                        else if (_iva == "5.00")
                        {
                            purchase_invoice_detail.id_vat_group = db.app_vat_group.Where(x => x.name == "5%").FirstOrDefault().id_vat_group;
                        }
                        else
                        {
                            if (db.app_vat_group.Where(x => x.name == "Excento").FirstOrDefault() != null)
                            {
                                purchase_invoice_detail.id_vat_group = db.app_vat_group.Where(x => x.name == "Excento").FirstOrDefault().id_vat_group;
                            }
                        }

                        decimal cotiz1 = Convert.ToDecimal((row["COTIZACION1"] is DBNull) ? 1 : Convert.ToDecimal(row["COTIZACION1"]));
                        // purchase_invoice_detail.unit_price = (Convert.ToDecimal(row["PRECIOVENTANETO"]) / purchase_invoice_detail.quantity) / cotiz1;

                        if (row["COSTOUNITARIO"] is DBNull)
                        {
                            purchase_invoice_detail.unit_cost = 0;
                        }
                        else
                        {
                            purchase_invoice_detail.unit_cost = Convert.ToDecimal(row["COSTOUNITARIO"]);
                        }
                        //Commit Sales Invoice Detail
                        purchase_invoice.purchase_invoice_detail.Add(purchase_invoice_detail);
                    }

                    if (purchase_invoice.Error == null)
                    {
                        try
                        {
                            purchase_invoice.State = System.Data.Entity.EntityState.Added;
                            purchase_invoice.IsSelected = true;

                            // db.purchase_invoice.Add(purchase_invoice);
                            IEnumerable<DbEntityValidationResult> validationresult = db.GetValidationErrors();
                            if (validationresult.Count() == 0)
                            {
                                db.SaveChanges();
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }

                        //Sales Brillo
                        //if (reader.GetInt32(10) == 1)
                        //{
                        //    entity.Brillo.Approve.SalesInvoice salesBrillo = new entity.Brillo.Approve.SalesInvoice();
                        //    salesBrillo.Start(ref db, sales_invoice);
                        //    sales_invoice.status = 0; ?????
                        //}
                        //else if (reader.GetInt32(10))
                        //{
                        //    entity.Brillo.Approve.SalesInvoice salesBrillo = new entity.Brillo.Approve.SalesInvoice();
                        //    salesBrillo.Start(ref db, sales_invoice);
                        //    entity.Brillo.Annul.SalesInvoice salesAnullBrillo = new entity.Brillo.Annul.SalesInvoice();
                        //    salesAnullBrillo.Start(ref db, sales_invoice);
                        //    sales_invoice.status = 0; ?????
                        //}

                        value += 1;
                        Dispatcher.BeginInvoke((Action)(() => progPurchase.Value = value));
                        Dispatcher.BeginInvoke((Action)(() =>purchaseValue.Text = value.ToString()));
                    }
                    else
                    {
                        //Add code to include error contacts into
                        purchase_invoice_ErrorList.Add(purchase_invoice);
                    }
                }
            }
               // reader.Close();
            cmd.Dispose();
            conn.Close();

            _customer_Current = _customer_Max;
        }
Esempio n. 42
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aggregate"></param>
 public void remove(contact aggregate)
 {
     _contacts.Remove(aggregate);
 }
Esempio n. 43
0
 public void CreateNewContact(contact contact)
 {
     context.contacts.Add(contact);
     context.SaveChanges();
 }
Esempio n. 44
0
        private era_evacuationfile CreateEvacuationFile(EssContext essContext, contact primaryContact, string fileId, string?paperFileNumber = null)
        {
            var file = new era_evacuationfile()
            {
                era_evacuationfileid   = Guid.NewGuid(),
                era_name               = fileId,
                era_evacuationfiledate = DateTime.UtcNow,
                era_securityphrase     = EvacuationFileSecurityPhrase,
                era_paperbasedessfile  = paperFileNumber
            };

            essContext.AddToera_evacuationfiles(file);
            essContext.SetLink(file, nameof(era_evacuationfile.era_TaskId), this.activeTask);
            var needsAssessment = new era_needassessment
            {
                era_needassessmentid    = Guid.NewGuid(),
                era_needsassessmenttype = (int)NeedsAssessmentTypeOptionSet.Preliminary,
                era_insurancecoverage   = (int)InsuranceOptionOptionSet.Unknown
            };

            essContext.AddToera_needassessments(needsAssessment);

            essContext.SetLink(file, nameof(era_evacuationfile.era_CurrentNeedsAssessmentid), needsAssessment);
            essContext.AddLink(file, nameof(era_evacuationfile.era_needsassessment_EvacuationFile), needsAssessment);
            essContext.SetLink(file, nameof(era_evacuationfile.era_Registrant), primaryContact);

            var primaryMember = new era_householdmember
            {
                era_householdmemberid   = Guid.NewGuid(),
                era_dateofbirth         = primaryContact.birthdate,
                era_firstname           = primaryContact.firstname,
                era_lastname            = primaryContact.lastname,
                era_gender              = primaryContact.gendercode,
                era_initials            = primaryContact.era_initial,
                era_isprimaryregistrant = true
            };

            var householdMembers = Enumerable.Range(1, Random.Shared.Next(1, 5)).Select(i => new era_householdmember
            {
                era_householdmemberid   = Guid.NewGuid(),
                era_dateofbirth         = new Date(2000 + i, i, i),
                era_firstname           = $"{testPrefix}-member-first-{i}",
                era_lastname            = $"{testPrefix}-member-last-{i}",
                era_gender              = Random.Shared.Next(1, 3),
                era_isprimaryregistrant = false
            }).Prepend(primaryMember)
                                   .Append(new era_householdmember
            {
                era_householdmemberid   = Guid.NewGuid(),
                era_dateofbirth         = new Date(1998, 1, 2),
                era_firstname           = $"{testPrefix}-member-no-registrant-first",
                era_lastname            = $"{testPrefix}-member-no-registrant-last",
                era_gender              = Random.Shared.Next(1, 3),
                era_isprimaryregistrant = false
            }).ToArray();

            foreach (var member in householdMembers)
            {
                essContext.AddToera_householdmembers(member);
                essContext.SetLink(member, nameof(era_householdmember.era_EvacuationFileid), file);
                essContext.AddLink(member, nameof(era_householdmember.era_era_householdmember_era_needassessment), needsAssessment);
                if (member.era_isprimaryregistrant == true)
                {
                    essContext.SetLink(member, nameof(era_householdmember.era_Registrant), primaryContact);
                    essContext.SetLink(file, nameof(era_evacuationfile.era_Registrant), primaryContact);
                }
            }

            file.era_era_evacuationfile_era_householdmember_EvacuationFileid = new Collection <era_householdmember>(householdMembers);
            return(file);
        }
Esempio n. 45
0
        public void adddatacontact(contact contact, cntrl.ExtendedTreeView treeview)
        {
            production_order_detail production_order_detail = (production_order_detail)treeview.SelectedItem_;

            if (production_order_detail != null)
            {
                if (contact != null)
                {
                    //Product
                    int id = Convert.ToInt32(((contact)contact).id_contact);
                    if (id > 0)
                    {
                        production_execution        _production_execution        = (production_execution)production_executionViewSource.View.CurrentItem;
                        production_execution_detail _production_execution_detail = new entity.production_execution_detail();

                        //Check for contact
                        _production_execution_detail.id_contact = ((contact)contact).id_contact;
                        _production_execution_detail.contact    = contact;
                        _production_execution_detail.quantity   = 1;
                        _production_execution_detail.item       = production_order_detail.item;
                        _production_execution_detail.id_item    = production_order_detail.item.id_item;
                        _production_execution.RaisePropertyChanged("quantity");
                        _production_execution_detail.is_input = true;
                        _production_execution_detail.name     = contact.name + ": " + production_order_detail.name;

                        if (production_order_detail.id_project_task > 0)
                        {
                            _production_execution_detail.id_project_task = production_order_detail.id_project_task;
                        }

                        //Gets the Employee's contracts Hourly Rate.
                        hr_contract contract = ExecutionDB.hr_contract.Where(x => x.id_contact == id && x.is_active).FirstOrDefault();
                        if (contract != null)
                        {
                            _production_execution_detail.unit_cost = contract.Hourly;
                        }

                        if (production_order_detail.item.id_item_type == item.item_type.Service)
                        {
                            if (cmbcoefficient.SelectedValue != null)
                            {
                                _production_execution_detail.id_time_coefficient = (int)cmbcoefficient.SelectedValue;
                            }

                            string start_date = string.Format("{0} {1}", dtpstartdate.Text, dtpstarttime.Text);
                            _production_execution_detail.start_date = Convert.ToDateTime(start_date);
                            string end_date = string.Format("{0} {1}", dtpenddate.Text, dtpendtime.Text);
                            _production_execution_detail.end_date = Convert.ToDateTime(end_date);

                            _production_execution_detail.id_production_execution = _production_execution.id_production_execution;
                            _production_execution_detail.production_execution    = _production_execution;
                            _production_execution_detail.id_project_task         = production_order_detail.id_project_task;
                            _production_execution_detail.id_order_detail         = production_order_detail.id_order_detail;
                            _production_execution_detail.production_order_detail = production_order_detail;

                            ExecutionDB.production_execution_detail.Add(_production_execution_detail);
                            RefreshData();
                        }
                        else if (production_order_detail.item.id_item_type == item.item_type.ServiceContract)
                        {
                            if (cmbcoefficient.SelectedValue != null)
                            {
                                _production_execution_detail.id_time_coefficient = (int)cmbsccoefficient.SelectedValue;
                            }

                            string start_date = string.Format("{0} {1}", dtpscstartdate.Text, dtpscstarttime.Text);
                            _production_execution_detail.start_date = Convert.ToDateTime(start_date);
                            string end_date = string.Format("{0} {1}", dtpscenddate.Text, dtpscendtime.Text);
                            _production_execution_detail.end_date = Convert.ToDateTime(end_date);

                            _production_execution_detail.id_production_execution = _production_execution.id_production_execution;
                            _production_execution_detail.production_execution    = _production_execution;
                            _production_execution_detail.id_project_task         = production_order_detail.id_project_task;
                            _production_execution_detail.id_order_detail         = production_order_detail.id_order_detail;
                            _production_execution_detail.production_order_detail = production_order_detail;

                            ExecutionDB.production_execution_detail.Add(_production_execution_detail);

                            RefreshData();
                        }
                    }
                }
            }
            else
            {
                toolBar.msgWarning("select Production order for insert");
            }
        }
Esempio n. 46
0
        private void CreateEvacueeSupports(EssContext essContext, era_evacuationfile file, contact contact, era_essteamuser creator, string prefix)
        {
            var referralSupportTypes  = new[] { 174360001, 174360002, 174360003, 174360004, 174360007 };
            var etransferSupportTypes = new[] { 174360000, 174360005, 174360006, 174360008 };

            var referrals = referralSupportTypes.Select((t, i) => new era_evacueesupport
            {
                era_evacueesupportid    = Guid.NewGuid(),
                era_suppliernote        = $"{prefix}-ref-{i}",
                era_validfrom           = DateTime.UtcNow.AddDays(-3),
                era_validto             = DateTime.UtcNow.AddDays(3),
                era_supporttype         = t,
                era_supportdeliverytype = 174360000, //referral
                statuscode = 1,                      //active
                statecode  = 0
            }).ToArray();
            var etransfers = etransferSupportTypes.Select((t, i) => new era_evacueesupport
            {
                era_evacueesupportid    = Guid.NewGuid(),
                era_suppliernote        = $"{prefix}-etr-{i}",
                era_validfrom           = DateTime.UtcNow.AddDays(-3),
                era_validto             = DateTime.UtcNow.AddDays(3),
                era_supporttype         = t,
                era_supportdeliverytype = 174360001, //etransfer
                era_totalamount         = 100m,
                statuscode = 174360002,              //approved
                statecode  = 0
            }).ToArray();

            foreach (var support in referrals)
            {
                essContext.AddToera_evacueesupports(support);
                essContext.AddLink(file, nameof(era_evacuationfile.era_era_evacuationfile_era_evacueesupport_ESSFileId), support);
                essContext.SetLink(support, nameof(era_evacueesupport.era_IssuedById), creator);
            }

            foreach (var support in etransfers)
            {
                essContext.AddToera_evacueesupports(support);
                essContext.AddLink(file, nameof(era_evacuationfile.era_era_evacuationfile_era_evacueesupport_ESSFileId), support);
                essContext.SetLink(support, nameof(era_evacueesupport.era_IssuedById), creator);
                essContext.SetLink(support, nameof(era_evacueesupport.era_PayeeId), contact);
            }

            var supports         = referrals.Concat(etransfers).ToArray();
            var householdMembers = file.era_era_evacuationfile_era_householdmember_EvacuationFileid.ToArray();

            foreach (var support in supports)
            {
                var supportHouseholdMembers = householdMembers.TakeRandom();
                foreach (var member in supportHouseholdMembers)
                {
                    essContext.AddLink(member, nameof(era_householdmember.era_era_householdmember_era_evacueesupport), support);
                }
            }
        }
        public void nullBatchData()
        {
            var litleBatchRequest = new batchRequest(memoryStreams);

            var authorization = new authorization();
            authorization.reportGroup = "Planets";
            authorization.orderId = "12344";
            authorization.amount = 106;
            authorization.orderSource = orderSourceType.ecommerce;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "414100000000000000";
            card.expDate = "1210";
            authorization.card = card; //This needs to compile

            litleBatchRequest.addAuthorization(authorization);
            try
            {
                litleBatchRequest.addAuthorization(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var reversal = new authReversal();
            reversal.litleTxnId = 12345678000L;
            reversal.amount = 106;
            reversal.payPalNotes = "Notes";

            litleBatchRequest.addAuthReversal(reversal);
            try
            {
                litleBatchRequest.addAuthReversal(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var capture = new capture();
            capture.litleTxnId = 123456000;
            capture.amount = 106;
            capture.payPalNotes = "Notes";

            litleBatchRequest.addCapture(capture);
            try
            {
                litleBatchRequest.addCapture(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var capturegivenauth = new captureGivenAuth();
            capturegivenauth.amount = 106;
            capturegivenauth.orderId = "12344";
            var authInfo = new authInformation();
            var authDate = new DateTime(2002, 10, 9);
            authInfo.authDate = authDate;
            authInfo.authCode = "543216";
            authInfo.authAmount = 12345;
            capturegivenauth.authInformation = authInfo;
            capturegivenauth.orderSource = orderSourceType.ecommerce;
            capturegivenauth.card = card;

            litleBatchRequest.addCaptureGivenAuth(capturegivenauth);
            try
            {
                litleBatchRequest.addCaptureGivenAuth(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var creditObj = new credit();
            creditObj.amount = 106;
            creditObj.orderId = "2111";
            creditObj.orderSource = orderSourceType.ecommerce;
            creditObj.card = card;

            litleBatchRequest.addCredit(creditObj);
            try
            {
                litleBatchRequest.addCredit(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var echeckcredit = new echeckCredit();
            echeckcredit.amount = 12L;
            echeckcredit.orderId = "12345";
            echeckcredit.orderSource = orderSourceType.ecommerce;
            var echeck = new echeckType();
            echeck.accType = echeckAccountTypeEnum.Checking;
            echeck.accNum = "12345657890";
            echeck.routingNum = "011201995";
            echeck.checkNum = "123455";
            echeckcredit.echeck = echeck;
            var billToAddress = new contact();
            billToAddress.name = "Bob";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "litle.com";
            echeckcredit.billToAddress = billToAddress;

            litleBatchRequest.addEcheckCredit(echeckcredit);
            try
            {
                litleBatchRequest.addEcheckCredit(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var echeckredeposit = new echeckRedeposit();
            echeckredeposit.litleTxnId = 123456;
            echeckredeposit.echeck = echeck;

            litleBatchRequest.addEcheckRedeposit(echeckredeposit);
            try
            {
                litleBatchRequest.addEcheckRedeposit(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var echeckSaleObj = new echeckSale();
            echeckSaleObj.amount = 123456;
            echeckSaleObj.orderId = "12345";
            echeckSaleObj.orderSource = orderSourceType.ecommerce;
            echeckSaleObj.echeck = echeck;
            echeckSaleObj.billToAddress = billToAddress;

            litleBatchRequest.addEcheckSale(echeckSaleObj);
            try
            {
                litleBatchRequest.addEcheckSale(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var echeckVerificationObject = new echeckVerification();
            echeckVerificationObject.amount = 123456;
            echeckVerificationObject.orderId = "12345";
            echeckVerificationObject.orderSource = orderSourceType.ecommerce;
            echeckVerificationObject.echeck = echeck;
            echeckVerificationObject.billToAddress = billToAddress;

            litleBatchRequest.addEcheckVerification(echeckVerificationObject);
            try
            {
                litleBatchRequest.addEcheckVerification(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var forcecapture = new forceCapture();
            forcecapture.amount = 106;
            forcecapture.orderId = "12344";
            forcecapture.orderSource = orderSourceType.ecommerce;
            forcecapture.card = card;

            litleBatchRequest.addForceCapture(forcecapture);
            try
            {
                litleBatchRequest.addForceCapture(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var saleObj = new sale();
            saleObj.amount = 106;
            saleObj.litleTxnId = 123456;
            saleObj.orderId = "12344";
            saleObj.orderSource = orderSourceType.ecommerce;
            saleObj.card = card;

            litleBatchRequest.addSale(saleObj);
            try
            {
                litleBatchRequest.addSale(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            var registerTokenRequest = new registerTokenRequestType();
            registerTokenRequest.orderId = "12344";
            registerTokenRequest.accountNumber = "1233456789103801";
            registerTokenRequest.reportGroup = "Planets";

            litleBatchRequest.addRegisterTokenRequest(registerTokenRequest);
            try
            {
                litleBatchRequest.addRegisterTokenRequest(null);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }

            try
            {
                litle.addBatch(litleBatchRequest);
            }
            catch (NullReferenceException e)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", e.Message);
            }
        }
Esempio n. 48
0
        public DynamicsTestData(IEssContextFactory essContextFactory)
        {
            var essContext = essContextFactory.Create();

            jurisdictions = essContext.era_jurisdictions.OrderBy(j => j.era_jurisdictionid).ToArray();
            canada        = essContext.era_countries.Where(c => c.era_countrycode == "CAN").Single();
            bc            = essContext.era_provinceterritorieses.Where(c => c.era_code == "BC").Single();
#if DEBUG
            this.testPrefix = $"autotest-dev";
#else
            this.testPrefix = $"autotest-{TestHelper.GenerateNewUniqueId(string.Empty)}";
#endif
            this.activeTaskId   = testPrefix + "-active-task";
            this.inactiveTaskId = testPrefix + "-inactive-task";

            var existingTeam = essContext.era_essteams.Where(t => t.era_name == testPrefix + "-team").SingleOrDefault();
            if (existingTeam != null)
            {
                essContext.LoadProperty(existingTeam, nameof(era_essteam.era_ESSTeam_ESSTeamArea_ESSTeamID));
                this.testTeam = existingTeam;

                this.CreateTeamMember(essContext, testTeam, Guid.NewGuid(), "-second");
                CreateTeamMember(essContext, testTeam, Guid.NewGuid(), "-third");
                CreateTeamMember(essContext, testTeam, Guid.NewGuid(), "-fourth");
            }
            else
            {
                this.testTeam = CreateTeam(essContext, Guid.NewGuid());
            }
            var otherTeam = essContext.era_essteams.Where(t => t.era_name == testPrefix + "-team-other").SingleOrDefault();
            if (otherTeam != null)
            {
                essContext.LoadProperty(otherTeam, nameof(era_essteam.era_ESSTeam_ESSTeamArea_ESSTeamID));
                this.otherTestTeam = otherTeam;
            }
            else
            {
                this.otherTestTeam = CreateTeam(essContext, Guid.NewGuid(), "-other");
            }

            this.activeTask = essContext.era_tasks.Where(t => t.era_name == activeTaskId).SingleOrDefault() ?? CreateTask(essContext, activeTaskId, DateTime.UtcNow);

            this.inactiveTask = essContext.era_tasks.Where(t => t.era_name == activeTaskId).SingleOrDefault() ?? CreateTask(essContext, inactiveTaskId, DateTime.UtcNow.AddDays(-7));

            this.tier4TeamMember = essContext.era_essteamusers.Where(tu => tu.era_firstname == this.testPrefix + "-first" && tu.era_lastname == this.testPrefix + "-last").SingleOrDefault()
                                   ?? CreateTeamMember(essContext, testTeam, Guid.NewGuid());

            this.otherTeamMember = essContext.era_essteamusers.Where(tu => tu.era_firstname == this.testPrefix + "-first-other" && tu.era_lastname == this.testPrefix + "-last-other").SingleOrDefault()
                                   ?? CreateTeamMember(essContext, this.otherTestTeam, Guid.NewGuid(), "-other", EMBC.ESS.Resources.Teams.TeamUserRoleOptionSet.Tier1);

            this.testContact = essContext.contacts.Where(c => c.firstname == this.testPrefix + "-first" && c.lastname == this.testPrefix + "-last").SingleOrDefault() ?? CreateContact(essContext);

            this.supplierA        = essContext.era_suppliers.Where(c => c.era_name == testPrefix + "-supplier-A").SingleOrDefault() ?? CreateSupplier(essContext, "A", this.testTeam);
            this.supplierB        = essContext.era_suppliers.Where(c => c.era_name == testPrefix + "-supplier-B").SingleOrDefault() ?? CreateSupplier(essContext, "B", this.testTeam);
            this.supplierC        = essContext.era_suppliers.Where(c => c.era_name == testPrefix + "-supplier-C").SingleOrDefault() ?? CreateSupplier(essContext, "C", this.otherTestTeam);
            this.inactiveSupplier = essContext.era_suppliers.Where(c => c.era_name == testPrefix + "-supplier-inactive").SingleOrDefault() ?? CreateSupplier(essContext, "inactive", null);

            var evacuationfile = essContext.era_evacuationfiles
                                 .Expand(f => f.era_CurrentNeedsAssessmentid)
                                 .Expand(f => f.era_Registrant)
                                 .Where(f => f.era_name == testPrefix + "-digital").SingleOrDefault();

            if (evacuationfile == null)
            {
                evacuationfile = CreateEvacuationFile(essContext, this.testContact, testPrefix + "-digital");
            }
            else
            {
                essContext.LoadProperty(evacuationfile, nameof(era_evacuationfile.era_era_evacuationfile_era_householdmember_EvacuationFileid));
                CreateEvacueeSupports(essContext, evacuationfile, this.testContact, this.tier4TeamMember, testPrefix);
            }

            var paperEvacuationfile = essContext.era_evacuationfiles
                                      .Expand(f => f.era_CurrentNeedsAssessmentid)
                                      .Expand(f => f.era_Registrant)
                                      .Where(f => f.era_name == testPrefix + "-paper").SingleOrDefault();

            if (paperEvacuationfile == null)
            {
                paperEvacuationfile = CreateEvacuationFile(essContext, this.testContact, testPrefix + "-paper", testPrefix + "-paper");
                CreateEvacueeSupports(essContext, paperEvacuationfile, this.testContact, this.tier4TeamMember, testPrefix);
            }
            else
            {
                essContext.LoadProperty(paperEvacuationfile, nameof(era_evacuationfile.era_era_evacuationfile_era_householdmember_EvacuationFileid));
            }

            essContext.SaveChanges();

            essContext.DeactivateObject(this.inactiveSupplier, 2);
            essContext.SaveChanges();
            essContext.DetachAll();

            this.testEvacuationfile = essContext.era_evacuationfiles
                                      .Expand(f => f.era_CurrentNeedsAssessmentid)
                                      .Expand(f => f.era_Registrant)
                                      .Where(f => f.era_evacuationfileid == evacuationfile.era_evacuationfileid).Single();

            essContext.LoadProperty(this.testEvacuationfile, nameof(era_evacuationfile.era_era_evacuationfile_era_evacueesupport_ESSFileId));
            essContext.LoadProperty(this.testEvacuationfile, nameof(era_evacuationfile.era_era_evacuationfile_era_householdmember_EvacuationFileid));

            this.testPaperEvacuationFile = essContext.era_evacuationfiles
                                           .Expand(f => f.era_CurrentNeedsAssessmentid)
                                           .Expand(f => f.era_Registrant)
                                           .Where(f => f.era_evacuationfileid == paperEvacuationfile.era_evacuationfileid).Single();

            essContext.LoadProperty(this.testPaperEvacuationFile, nameof(era_evacuationfile.era_era_evacuationfile_era_evacueesupport_ESSFileId));
            essContext.LoadProperty(this.testPaperEvacuationFile, nameof(era_evacuationfile.era_era_evacuationfile_era_householdmember_EvacuationFileid));

            essContext.DetachAll();
            this.essContextFactory = essContextFactory;
        }
        public void SimpleBatch()
        {
            var litleBatchRequest = new batchRequest(memoryStreams);

            var authorization = new authorization();
            authorization.reportGroup = "Planets";
            authorization.orderId = "12344";
            authorization.amount = 106;
            authorization.orderSource = orderSourceType.ecommerce;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4100000000000001";
            card.expDate = "1210";
            authorization.card = card;

            litleBatchRequest.addAuthorization(authorization);

            var authorization2 = new authorization();
            authorization2.reportGroup = "Planets";
            authorization2.orderId = "12345";
            authorization2.amount = 106;
            authorization2.orderSource = orderSourceType.ecommerce;
            var card2 = new cardType();
            card2.type = methodOfPaymentTypeEnum.VI;
            card2.number = "4242424242424242";
            card2.expDate = "1210";
            authorization2.card = card2;

            litleBatchRequest.addAuthorization(authorization2);

            var reversal = new authReversal();
            reversal.litleTxnId = 12345678000L;
            reversal.amount = 106;
            reversal.payPalNotes = "Notes";

            litleBatchRequest.addAuthReversal(reversal);

            var reversal2 = new authReversal();
            reversal2.litleTxnId = 12345678900L;
            reversal2.amount = 106;
            reversal2.payPalNotes = "Notes";

            litleBatchRequest.addAuthReversal(reversal2);

            var capture = new capture();
            capture.litleTxnId = 123456000;
            capture.amount = 106;
            capture.payPalNotes = "Notes";

            litleBatchRequest.addCapture(capture);

            var capture2 = new capture();
            capture2.litleTxnId = 123456700;
            capture2.amount = 106;
            capture2.payPalNotes = "Notes";

            litleBatchRequest.addCapture(capture2);

            var capturegivenauth = new captureGivenAuth();
            capturegivenauth.amount = 106;
            capturegivenauth.orderId = "12344";
            var authInfo = new authInformation();
            var authDate = new DateTime(2002, 10, 9);
            authInfo.authDate = authDate;
            authInfo.authCode = "543216";
            authInfo.authAmount = 12345;
            capturegivenauth.authInformation = authInfo;
            capturegivenauth.orderSource = orderSourceType.ecommerce;
            capturegivenauth.card = card;

            litleBatchRequest.addCaptureGivenAuth(capturegivenauth);

            var capturegivenauth2 = new captureGivenAuth();
            capturegivenauth2.amount = 106;
            capturegivenauth2.orderId = "12344";
            var authInfo2 = new authInformation();
            authDate = new DateTime(2003, 10, 9);
            authInfo2.authDate = authDate;
            authInfo2.authCode = "543216";
            authInfo2.authAmount = 12345;
            capturegivenauth2.authInformation = authInfo;
            capturegivenauth2.orderSource = orderSourceType.ecommerce;
            capturegivenauth2.card = card2;

            litleBatchRequest.addCaptureGivenAuth(capturegivenauth2);

            var creditObj = new credit();
            creditObj.amount = 106;
            creditObj.orderId = "2111";
            creditObj.orderSource = orderSourceType.ecommerce;
            creditObj.card = card;

            litleBatchRequest.addCredit(creditObj);

            var creditObj2 = new credit();
            creditObj2.amount = 106;
            creditObj2.orderId = "2111";
            creditObj2.orderSource = orderSourceType.ecommerce;
            creditObj2.card = card2;

            litleBatchRequest.addCredit(creditObj2);

            var echeckcredit = new echeckCredit();
            echeckcredit.amount = 12L;
            echeckcredit.orderId = "12345";
            echeckcredit.orderSource = orderSourceType.ecommerce;
            var echeck = new echeckType();
            echeck.accType = echeckAccountTypeEnum.Checking;
            echeck.accNum = "1099999903";
            echeck.routingNum = "011201995";
            echeck.checkNum = "123455";
            echeckcredit.echeck = echeck;
            var billToAddress = new contact();
            billToAddress.name = "Bob";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "litle.com";
            echeckcredit.billToAddress = billToAddress;

            litleBatchRequest.addEcheckCredit(echeckcredit);

            var echeckcredit2 = new echeckCredit();
            echeckcredit2.amount = 12L;
            echeckcredit2.orderId = "12346";
            echeckcredit2.orderSource = orderSourceType.ecommerce;
            var echeck2 = new echeckType();
            echeck2.accType = echeckAccountTypeEnum.Checking;
            echeck2.accNum = "1099999903";
            echeck2.routingNum = "011201995";
            echeck2.checkNum = "123456";
            echeckcredit2.echeck = echeck2;
            var billToAddress2 = new contact();
            billToAddress2.name = "Mike";
            billToAddress2.city = "Lowell";
            billToAddress2.state = "MA";
            billToAddress2.email = "litle.com";
            echeckcredit2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckCredit(echeckcredit2);

            var echeckredeposit = new echeckRedeposit();
            echeckredeposit.litleTxnId = 123456;
            echeckredeposit.echeck = echeck;

            litleBatchRequest.addEcheckRedeposit(echeckredeposit);

            var echeckredeposit2 = new echeckRedeposit();
            echeckredeposit2.litleTxnId = 123457;
            echeckredeposit2.echeck = echeck2;

            litleBatchRequest.addEcheckRedeposit(echeckredeposit2);

            var echeckSaleObj = new echeckSale();
            echeckSaleObj.amount = 123456;
            echeckSaleObj.orderId = "12345";
            echeckSaleObj.orderSource = orderSourceType.ecommerce;
            echeckSaleObj.echeck = echeck;
            echeckSaleObj.billToAddress = billToAddress;

            litleBatchRequest.addEcheckSale(echeckSaleObj);

            var echeckSaleObj2 = new echeckSale();
            echeckSaleObj2.amount = 123456;
            echeckSaleObj2.orderId = "12346";
            echeckSaleObj2.orderSource = orderSourceType.ecommerce;
            echeckSaleObj2.echeck = echeck2;
            echeckSaleObj2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckSale(echeckSaleObj2);

            var echeckPreNoteSaleObj1 = new echeckPreNoteSale();
            echeckPreNoteSaleObj1.orderId = "12345";
            echeckPreNoteSaleObj1.orderSource = orderSourceType.ecommerce;
            echeckPreNoteSaleObj1.echeck = echeck;
            echeckPreNoteSaleObj1.billToAddress = billToAddress;

            litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleObj1);

            var echeckPreNoteSaleObj2 = new echeckPreNoteSale();
            echeckPreNoteSaleObj2.orderId = "12345";
            echeckPreNoteSaleObj2.orderSource = orderSourceType.ecommerce;
            echeckPreNoteSaleObj2.echeck = echeck2;
            echeckPreNoteSaleObj2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleObj2);

            var echeckPreNoteCreditObj1 = new echeckPreNoteCredit();
            echeckPreNoteCreditObj1.orderId = "12345";
            echeckPreNoteCreditObj1.orderSource = orderSourceType.ecommerce;
            echeckPreNoteCreditObj1.echeck = echeck;
            echeckPreNoteCreditObj1.billToAddress = billToAddress;

            litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditObj1);

            var echeckPreNoteCreditObj2 = new echeckPreNoteCredit();
            echeckPreNoteCreditObj2.orderId = "12345";
            echeckPreNoteCreditObj2.orderSource = orderSourceType.ecommerce;
            echeckPreNoteCreditObj2.echeck = echeck2;
            echeckPreNoteCreditObj2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditObj2);

            var echeckVerificationObject = new echeckVerification();
            echeckVerificationObject.amount = 123456;
            echeckVerificationObject.orderId = "12345";
            echeckVerificationObject.orderSource = orderSourceType.ecommerce;
            echeckVerificationObject.echeck = echeck;
            echeckVerificationObject.billToAddress = billToAddress;

            litleBatchRequest.addEcheckVerification(echeckVerificationObject);

            var echeckVerificationObject2 = new echeckVerification();
            echeckVerificationObject2.amount = 123456;
            echeckVerificationObject2.orderId = "12346";
            echeckVerificationObject2.orderSource = orderSourceType.ecommerce;
            echeckVerificationObject2.echeck = echeck2;
            echeckVerificationObject2.billToAddress = billToAddress2;

            litleBatchRequest.addEcheckVerification(echeckVerificationObject2);

            var forcecapture = new forceCapture();
            forcecapture.amount = 106;
            forcecapture.orderId = "12344";
            forcecapture.orderSource = orderSourceType.ecommerce;
            forcecapture.card = card;

            litleBatchRequest.addForceCapture(forcecapture);

            var forcecapture2 = new forceCapture();
            forcecapture2.amount = 106;
            forcecapture2.orderId = "12345";
            forcecapture2.orderSource = orderSourceType.ecommerce;
            forcecapture2.card = card2;

            litleBatchRequest.addForceCapture(forcecapture2);

            var saleObj = new sale();
            saleObj.amount = 106;
            saleObj.litleTxnId = 123456;
            saleObj.orderId = "12344";
            saleObj.orderSource = orderSourceType.ecommerce;
            saleObj.card = card;

            litleBatchRequest.addSale(saleObj);

            var saleObj2 = new sale();
            saleObj2.amount = 106;
            saleObj2.litleTxnId = 123456;
            saleObj2.orderId = "12345";
            saleObj2.orderSource = orderSourceType.ecommerce;
            saleObj2.card = card2;

            litleBatchRequest.addSale(saleObj2);

            var registerTokenRequest = new registerTokenRequestType();
            registerTokenRequest.orderId = "12344";
            registerTokenRequest.accountNumber = "1233456789103801";
            registerTokenRequest.reportGroup = "Planets";

            litleBatchRequest.addRegisterTokenRequest(registerTokenRequest);

            var registerTokenRequest2 = new registerTokenRequestType();
            registerTokenRequest2.orderId = "12345";
            registerTokenRequest2.accountNumber = "1233456789103801";
            registerTokenRequest2.reportGroup = "Planets";

            litleBatchRequest.addRegisterTokenRequest(registerTokenRequest2);

            var updateCardValidationNumOnToken = new updateCardValidationNumOnToken();
            updateCardValidationNumOnToken.orderId = "12344";
            updateCardValidationNumOnToken.cardValidationNum = "123";
            updateCardValidationNumOnToken.litleToken = "4100000000000001";

            litleBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken);

            var updateCardValidationNumOnToken2 = new updateCardValidationNumOnToken();
            updateCardValidationNumOnToken2.orderId = "12345";
            updateCardValidationNumOnToken2.cardValidationNum = "123";
            updateCardValidationNumOnToken2.litleToken = "4242424242424242";

            litleBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken2);
            litle.addBatch(litleBatchRequest);

            var litleResponse = litle.sendToLitleWithStream();

            Assert.NotNull(litleResponse);
            Assert.AreEqual("0", litleResponse.response);
            Assert.AreEqual("Valid Format", litleResponse.message);

            var litleBatchResponse = litleResponse.nextBatchResponse();
            while (litleBatchResponse != null)
            {
                var authorizationResponse = litleBatchResponse.nextAuthorizationResponse();
                while (authorizationResponse != null)
                {
                    Assert.AreEqual("000", authorizationResponse.response);

                    authorizationResponse = litleBatchResponse.nextAuthorizationResponse();
                }

                var authReversalResponse = litleBatchResponse.nextAuthReversalResponse();
                while (authReversalResponse != null)
                {
                    Assert.AreEqual("360", authReversalResponse.response);

                    authReversalResponse = litleBatchResponse.nextAuthReversalResponse();
                }

                var captureResponse = litleBatchResponse.nextCaptureResponse();
                while (captureResponse != null)
                {
                    Assert.AreEqual("360", captureResponse.response);

                    captureResponse = litleBatchResponse.nextCaptureResponse();
                }

                var captureGivenAuthResponse = litleBatchResponse.nextCaptureGivenAuthResponse();
                while (captureGivenAuthResponse != null)
                {
                    Assert.AreEqual("000", captureGivenAuthResponse.response);

                    captureGivenAuthResponse = litleBatchResponse.nextCaptureGivenAuthResponse();
                }

                var creditResponse = litleBatchResponse.nextCreditResponse();
                while (creditResponse != null)
                {
                    Assert.AreEqual("000", creditResponse.response);

                    creditResponse = litleBatchResponse.nextCreditResponse();
                }

                var echeckCreditResponse = litleBatchResponse.nextEcheckCreditResponse();
                while (echeckCreditResponse != null)
                {
                    Assert.AreEqual("000", echeckCreditResponse.response);

                    echeckCreditResponse = litleBatchResponse.nextEcheckCreditResponse();
                }

                var echeckRedepositResponse = litleBatchResponse.nextEcheckRedepositResponse();
                while (echeckRedepositResponse != null)
                {
                    Assert.AreEqual("360", echeckRedepositResponse.response);

                    echeckRedepositResponse = litleBatchResponse.nextEcheckRedepositResponse();
                }

                var echeckSalesResponse = litleBatchResponse.nextEcheckSalesResponse();
                while (echeckSalesResponse != null)
                {
                    Assert.AreEqual("000", echeckSalesResponse.response);

                    echeckSalesResponse = litleBatchResponse.nextEcheckSalesResponse();
                }

                var echeckPreNoteSaleResponse = litleBatchResponse.nextEcheckPreNoteSaleResponse();
                while (echeckPreNoteSaleResponse != null)
                {
                    Assert.AreEqual("000", echeckPreNoteSaleResponse.response);

                    echeckPreNoteSaleResponse = litleBatchResponse.nextEcheckPreNoteSaleResponse();
                }

                var echeckPreNoteCreditResponse = litleBatchResponse.nextEcheckPreNoteCreditResponse();
                while (echeckPreNoteCreditResponse != null)
                {
                    Assert.AreEqual("000", echeckPreNoteCreditResponse.response);

                    echeckPreNoteCreditResponse = litleBatchResponse.nextEcheckPreNoteCreditResponse();
                }

                var echeckVerificationResponse = litleBatchResponse.nextEcheckVerificationResponse();
                while (echeckVerificationResponse != null)
                {
                    Assert.AreEqual("957", echeckVerificationResponse.response);

                    echeckVerificationResponse = litleBatchResponse.nextEcheckVerificationResponse();
                }

                var forceCaptureResponse = litleBatchResponse.nextForceCaptureResponse();
                while (forceCaptureResponse != null)
                {
                    Assert.AreEqual("000", forceCaptureResponse.response);

                    forceCaptureResponse = litleBatchResponse.nextForceCaptureResponse();
                }

                var registerTokenResponse = litleBatchResponse.nextRegisterTokenResponse();
                while (registerTokenResponse != null)
                {
                    Assert.AreEqual("820", registerTokenResponse.response);

                    registerTokenResponse = litleBatchResponse.nextRegisterTokenResponse();
                }

                var saleResponse = litleBatchResponse.nextSaleResponse();
                while (saleResponse != null)
                {
                    Assert.AreEqual("000", saleResponse.response);

                    saleResponse = litleBatchResponse.nextSaleResponse();
                }

                var updateCardValidationNumOnTokenResponse =
                    litleBatchResponse.nextUpdateCardValidationNumOnTokenResponse();
                while (updateCardValidationNumOnTokenResponse != null)
                {
                    Assert.AreEqual("823", updateCardValidationNumOnTokenResponse.response);

                    updateCardValidationNumOnTokenResponse =
                        litleBatchResponse.nextUpdateCardValidationNumOnTokenResponse();
                }

                litleBatchResponse = litleResponse.nextBatchResponse();
            }
        }
Esempio n. 50
0
        public void test2Auth()
        {
            authorization authorization = new authorization();

            authorization.orderId     = "2";
            authorization.amount      = 20020;
            authorization.orderSource = orderSourceType.ecommerce;
            contact contact = new contact();

            contact.name                = "Mike J. Hammer";
            contact.addressLine1        = "2 Main St.";
            contact.addressLine2        = "Apt. 222";
            contact.city                = "Riverside";
            contact.state               = "RI";
            contact.zip                 = "02915";
            contact.country             = countryTypeEnum.US;
            authorization.billToAddress = contact;
            cardType card = new cardType();

            card.type              = methodOfPaymentTypeEnum.MC;
            card.number            = "5112010000000003";
            card.expDate           = "0212";
            card.cardValidationNum = "261";
            authorization.card     = card;
            fraudCheckType authenticationvalue = new fraudCheckType();

            authenticationvalue.authenticationValue = "BwABBJQ1AgAAAAAgJDUCAAAAAAA=";
            authorization.cardholderAuthentication  = authenticationvalue;

            authorizationResponse response = litle.Authorize(authorization);

            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("22222", response.authCode);
            Assert.AreEqual("10", response.fraudResult.avsResult);
            Assert.AreEqual("M", response.fraudResult.cardValidationResult);

            capture capture = new capture();

            capture.litleTxnId = response.litleTxnId;
            captureResponse captureresponse = litle.Capture(capture);

            Assert.AreEqual("000", captureresponse.response);
            Assert.AreEqual("Approved", captureresponse.message);

            credit credit = new credit();

            credit.litleTxnId = captureresponse.litleTxnId;
            creditResponse creditResponse = litle.Credit(credit);

            Assert.AreEqual("000", creditResponse.response);
            Assert.AreEqual("Approved", creditResponse.message);

            voidTxn newvoid = new voidTxn();

            newvoid.litleTxnId = creditResponse.litleTxnId;
            litleOnlineResponseTransactionResponseVoidResponse voidResponse = litle.DoVoid(newvoid);

            Assert.AreEqual("000", voidResponse.response);
            Assert.AreEqual("Approved", voidResponse.message);
        }
Esempio n. 51
0
 base.PreSolve(contact, oldManifold);
Esempio n. 52
0
        private void SelectProduct_Thread(object sender, EventArgs e, purchase_order purchase_order, item item, contact contact)
        {
            purchase_order_detail purchase_order_detail = new purchase_order_detail();

            purchase_order_detail.purchase_order = purchase_order;
            Cognitivo.Purchase.OrderSetting OrderSetting = new Cognitivo.Purchase.OrderSetting();
            //ItemLink
            if (item != null)
            {
                if (purchase_order.purchase_order_detail.Where(a => a.id_item == item.id_item).FirstOrDefault() != null || OrderSetting.AllowDuplicateItems)
                {
                    //Item Exists in Context, so add to sum.
                    purchase_order_detail _purchase_order_detail = purchase_order.purchase_order_detail.Where(a => a.id_item == item.id_item).FirstOrDefault();
                    _purchase_order_detail.quantity += 1;

                    //Return because Item exists, and will +1 in Quantity
                    return;
                }
                else
                {
                    //If Item Exists in previous purchase... then get Last Cost. Problem, will get in stored value, in future we will need to add logic to convert into current currency.
                    if (PurchaseOrderDB.purchase_invoice_detail
                        .Where(x => x.id_item == item.id_item && x.purchase_invoice.id_contact == purchase_order.id_contact)
                        .OrderByDescending(y => y.purchase_invoice.trans_date)
                        .FirstOrDefault() != null)
                    {
                        purchase_order_detail.unit_cost = PurchaseOrderDB.purchase_invoice_detail
                                                          .Where(x => x.id_item == item.id_item && x.purchase_invoice.id_contact == purchase_order.id_contact)
                                                          .OrderByDescending(y => y.purchase_invoice.trans_date)
                                                          .FirstOrDefault().unit_cost;
                    }

                    //Item DOES NOT Exist in Context
                    purchase_order_detail.item             = item;
                    purchase_order_detail.id_item          = item.id_item;
                    purchase_order_detail.item_description = item.name;
                    purchase_order_detail.quantity         = 1;
                }
            }
            else
            {
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    purchase_order_detail.item_description = sbxItem.Text;
                }));
            }

            //Cost Center
            if (contact != null && contact.app_cost_center != null)
            {
                app_cost_center app_cost_center = contact.app_cost_center;
                if (app_cost_center.id_cost_center > 0)
                {
                    purchase_order_detail.id_cost_center = app_cost_center.id_cost_center;
                }
            }
            else
            {
                if (item != null)
                {
                    int id_cost_center = 0;

                    if (item.item_product != null)
                    {
                        if (PurchaseOrderDB.app_cost_center.Where(a => a.is_product == true && a.is_active == true && a.id_company == CurrentSession.Id_Company).FirstOrDefault() != null)
                        {
                            id_cost_center = Convert.ToInt32(PurchaseOrderDB.app_cost_center.Where(a => a.is_product == true && a.is_active == true && a.id_company == CurrentSession.Id_Company).FirstOrDefault().id_cost_center);
                        }
                        if (id_cost_center > 0)
                        {
                            purchase_order_detail.id_cost_center = id_cost_center;
                        }
                    }
                    else if (item.item_asset != null)
                    {
                        if (PurchaseOrderDB.app_cost_center.Where(a => a.is_fixedasset == true && a.is_active == true && a.id_company == CurrentSession.Id_Company).FirstOrDefault() != null)
                        {
                            id_cost_center = Convert.ToInt32(PurchaseOrderDB.app_cost_center.Where(a => a.is_fixedasset == true && a.is_active == true && a.id_company == CurrentSession.Id_Company).FirstOrDefault().id_cost_center);
                        }
                        if (id_cost_center > 0)
                        {
                            purchase_order_detail.id_cost_center = id_cost_center;
                        }
                    }
                }
                else
                {
                    int id_cost_center = 0;
                    if (PurchaseOrderDB.app_cost_center.Where(a => a.is_administrative == true && a.is_active == true && a.id_company == CurrentSession.Id_Company).FirstOrDefault() != null)
                    {
                        id_cost_center = Convert.ToInt32(PurchaseOrderDB.app_cost_center.Where(a => a.is_administrative == true && a.is_active == true && a.id_company == CurrentSession.Id_Company).FirstOrDefault().id_cost_center);
                    }
                    if (id_cost_center > 0)
                    {
                        purchase_order_detail.id_cost_center = id_cost_center;
                    }
                }
            }

            //VAT
            if (item != null)
            {
                if (item.id_vat_group > 0)
                {
                    purchase_order_detail.id_vat_group = item.id_vat_group;
                }
            }
            else if (PurchaseOrderDB.app_vat_group.Where(x => x.is_active == true && x.is_default == true && x.id_company == CurrentSession.Id_Company).FirstOrDefault() != null)
            {
                purchase_order_detail.id_vat_group = PurchaseOrderDB.app_vat_group.Where(x => x.is_active == true && x.is_default == true && x.id_company == CurrentSession.Id_Company).FirstOrDefault().id_vat_group;
            }

            Dispatcher.BeginInvoke((Action)(() =>
            {
                purchase_order.purchase_order_detail.Add(purchase_order_detail);
                purchase_orderpurchase_order_detailViewSource.View.Refresh();
                calculate_vat(sender, e);
            }));
        }
Esempio n. 53
0
        public static string AmloCustomerToXml(List <M_CustomerDTO> customerList, string path)
        {
            #region local variable
            List <AmloToCustomer> customerResultList = null;
            AmloToCustomer        customerData       = null;


            customerData = new AmloToCustomer();
            List <reportingdetail> reportingDetailList = new List <reportingdetail>();
            List <report>          reportList          = new List <report>();
            report          report = null;
            reportingdetail reportingdetailData = null;

            List <person> personList = new List <person>();
            person        personData = null;


            List <contact> contactList = new List <contact>();
            contact        contactData = null;
            address        addressData = null;
            #endregion


            foreach (M_CustomerDTO customerObj in customerList)
            {
                reportingdetailData = new reportingdetail()
                {
                    orgid = customerObj.JuristicIDNo, orgname = customerObj.RegBusinessName
                };

                reportingDetailList.Add(reportingdetailData);


                #region report
                //<report>
                report      = new report();
                contactList = new List <contact>();
                personList  = new List <person>();
                //<reportorgdetail branchcode="00000" orgname="ธนาคารเอเอ็นแซด (ไทย) จำกัด (มหาชน)" telno="022639700"/>
                report.reportingdetail = new reportingdetail()
                {
                    branchcode = customerObj.CustomerNo, orgname = customerObj.RegBusinessName, telno = customerObj.TelNo
                };

                //<dcn value="09-00107557000420-00000-255912-000084" doctype="1-05-9" revision="" date="" refdocno="" refdoctype=""/>
                report.dcn = new dcn()
                {
                    value = "09-00107557000420-00000-255912-000084", doctype = "1-05-9", revision = "", date = "", refdocno = "", refdoctype = ""
                };

                //<reporttype value="2"/>
                report.reportType = new reportType()
                {
                    value = "2"
                };
                #endregion

                #region Personal
                personData = new person()
                {
                    anothermethod        = "TRUE",
                    am_transactionmethod = "DOCUMENT",
                    value            = "TRANSACTING-PERSON",
                    relationship     = "SELF",
                    relationshipdesc = ""
                };


                personData.personName = new personName()
                {
                    type          = "LEGAL",
                    title         = "",
                    firstname     = "[NAV]",
                    middlename    = "",
                    lastname      = "",
                    dateofbirth   = "",
                    nationality   = "STATELESS",
                    legalpersonid = "[NAV]"
                };

                personData.occupation = new occupation()
                {
                    companyname = customerObj.RegBusinessName, businesstype = customerObj.PrimaryBusinessTypeCode, businesstype_desc = customerObj.PrimaryBusinessTypeDescription, occ_type = "99", occ_desc = "[NAV]",
                };

                foreach (M_Customer_Address custAdd in customerObj.AddressList)
                {
                    addressData = new address()
                    {
                        no          = "[NAV]",
                        moo         = "",
                        building    = "",
                        soi         = "",
                        road        = "",
                        subdistrict = "[NAV]",
                        address1    = custAdd.PrincipleAddress,
                        address2    = "",
                        district    = "[NAV]",
                        province    = custAdd.City,
                        zipcode     = custAdd.Zipcode,
                        countrycode = "TH"
                    };

                    contactData = new contact()
                    {
                        type = "ADDR", address = addressData
                    };

                    contactList.Add(contactData);

                    /* contactData = new contact() { type = "COMPANY-ADDR", noinfo = "TRUE" };
                     * contactList.Add(contactData);
                     * contactData = new contact() { type = "CONTACT-ADDR", noinfo = "TRUE" };
                     * contactList.Add(contactData);
                     */
                    break;
                }

                personData.contact = contactList;
                personList.Add(personData);
                #endregion

                report.person = personList;

                reportList.Add(report);
            }

            customerData.reportingdetail = reportingDetailList;
            customerData.report          = reportList;
            string data = string.Format("{0}", DTO.Util.XmlSerializerHelper.SerializeObjectToString(customerData));

            DTO.Util.Utility.WriteObject2File(path, string.Format("Customer{0}", DateTime.Now.ToString("yyMMddHHmm")), data, "xml");

            return(data);
        }
Esempio n. 54
0
        public void SimpleBatch()
        {
            if (this.preliveIsDown())
            {
                Assert.Ignore();
            }

            var cnpBatchRequest = new batchRequest();

            var authorization = new authorization
            {
                reportGroup = "Planets",
                orderId     = "12344",
                amount      = 106,
                orderSource = orderSourceType.ecommerce
            };
            var card = new cardType
            {
                type    = methodOfPaymentTypeEnum.VI,
                number  = "4100000000000001",
                expDate = "1210"
            };

            authorization.card = card;
            authorization.id   = "id";

            cnpBatchRequest.addAuthorization(authorization);

            var authorization2 = new authorization();

            authorization2.reportGroup = "Planets";
            authorization2.orderId     = "12345";
            authorization2.amount      = 106;
            authorization2.orderSource = orderSourceType.ecommerce;
            var card2 = new cardType();

            card2.type          = methodOfPaymentTypeEnum.VI;
            card2.number        = "4242424242424242";
            card2.expDate       = "1210";
            authorization2.card = card2;
            authorization2.id   = "id";

            cnpBatchRequest.addAuthorization(authorization2);

            var reversal = new authReversal();

            reversal.cnpTxnId    = 12345678000L;
            reversal.amount      = 106;
            reversal.payPalNotes = "Notes";
            reversal.id          = "id";

            cnpBatchRequest.addAuthReversal(reversal);

            var reversal2 = new authReversal();

            reversal2.cnpTxnId    = 12345678900L;
            reversal2.amount      = 106;
            reversal2.payPalNotes = "Notes";
            reversal2.id          = "id";

            cnpBatchRequest.addAuthReversal(reversal2);

            var giftCardAuthReversal = new giftCardAuthReversal();

            giftCardAuthReversal.id       = "id";
            giftCardAuthReversal.cnpTxnId = 12345678000L;
            var giftCardCardTypeAuthReversal = new giftCardCardType();

            giftCardCardTypeAuthReversal.type           = methodOfPaymentTypeEnum.GC;
            giftCardCardTypeAuthReversal.number         = "4100000000000001";
            giftCardCardTypeAuthReversal.expDate        = "1210";
            giftCardAuthReversal.card                   = giftCardCardTypeAuthReversal;
            giftCardAuthReversal.originalRefCode        = "123456";
            giftCardAuthReversal.originalAmount         = 1000;
            giftCardAuthReversal.originalTxnTime        = DateTime.Now;
            giftCardAuthReversal.originalSystemTraceId  = 123;
            giftCardAuthReversal.originalSequenceNumber = "123456";

            cnpBatchRequest.addGiftCardAuthReversal(giftCardAuthReversal);

            var capture = new capture();

            capture.cnpTxnId    = 123456000;
            capture.amount      = 106;
            capture.payPalNotes = "Notes";
            capture.id          = "id";

            cnpBatchRequest.addCapture(capture);

            var capture2 = new capture();

            capture2.cnpTxnId    = 123456700;
            capture2.amount      = 106;
            capture2.payPalNotes = "Notes";
            capture2.id          = "id";

            cnpBatchRequest.addCapture(capture2);

            var giftCardCapture = new giftCardCapture();

            giftCardCapture.id            = "id";
            giftCardCapture.cnpTxnId      = 12345678000L;
            giftCardCapture.captureAmount = 123456;
            var giftCardCardTypeCapture = new giftCardCardType();

            giftCardCardTypeCapture.type    = methodOfPaymentTypeEnum.GC;
            giftCardCardTypeCapture.number  = "4100000000000001";
            giftCardCardTypeCapture.expDate = "1210";
            giftCardCapture.card            = giftCardCardTypeCapture;
            giftCardCapture.originalRefCode = "123456";
            giftCardCapture.originalAmount  = 1000;
            giftCardCapture.originalTxnTime = DateTime.Now;

            cnpBatchRequest.addGiftCardCapture(giftCardCapture);

            var capturegivenauth = new captureGivenAuth();

            capturegivenauth.amount  = 106;
            capturegivenauth.orderId = "12344";
            var authInfo = new authInformation();
            var authDate = new DateTime(2002, 10, 9);

            authInfo.authDate   = authDate;
            authInfo.authCode   = "543216";
            authInfo.authAmount = 12345;
            capturegivenauth.authInformation = authInfo;
            capturegivenauth.orderSource     = orderSourceType.ecommerce;
            capturegivenauth.card            = card;
            capturegivenauth.id = "id";

            cnpBatchRequest.addCaptureGivenAuth(capturegivenauth);

            var capturegivenauth2 = new captureGivenAuth();

            capturegivenauth2.amount  = 106;
            capturegivenauth2.orderId = "12344";
            var authInfo2 = new authInformation();

            authDate             = new DateTime(2003, 10, 9);
            authInfo2.authDate   = authDate;
            authInfo2.authCode   = "543216";
            authInfo2.authAmount = 12345;
            capturegivenauth2.authInformation = authInfo;
            capturegivenauth2.orderSource     = orderSourceType.ecommerce;
            capturegivenauth2.card            = card2;
            capturegivenauth2.id = "id";

            cnpBatchRequest.addCaptureGivenAuth(capturegivenauth2);

            var creditObj = new credit();

            creditObj.amount      = 106;
            creditObj.orderId     = "2111";
            creditObj.orderSource = orderSourceType.ecommerce;
            creditObj.card        = card;
            creditObj.id          = "id";

            cnpBatchRequest.addCredit(creditObj);

            var creditObj2 = new credit();

            creditObj2.amount      = 106;
            creditObj2.orderId     = "2111";
            creditObj2.orderSource = orderSourceType.ecommerce;
            creditObj2.card        = card2;
            creditObj2.id          = "id";

            cnpBatchRequest.addCredit(creditObj2);

            var giftCardCredit = new giftCardCredit();

            giftCardCredit.id           = "id";
            giftCardCredit.cnpTxnId     = 12345678000L;
            giftCardCredit.creditAmount = 123456;
            var giftCardCardTypeCredit = new giftCardCardType();

            giftCardCardTypeCredit.type    = methodOfPaymentTypeEnum.GC;
            giftCardCardTypeCredit.number  = "4100000000000001";
            giftCardCardTypeCredit.expDate = "1210";
            giftCardCredit.card            = giftCardCardTypeCredit;
            giftCardCredit.orderId         = "123456";
            giftCardCredit.orderSource     = orderSourceType.ecommerce;

            cnpBatchRequest.addGiftCardCredit(giftCardCredit);

            var echeckcredit = new echeckCredit();

            echeckcredit.amount      = 12L;
            echeckcredit.orderId     = "12345";
            echeckcredit.orderSource = orderSourceType.ecommerce;
            var echeck = new echeckType();

            echeck.accType      = echeckAccountTypeEnum.Checking;
            echeck.accNum       = "1099999903";
            echeck.routingNum   = "011201995";
            echeck.checkNum     = "123455";
            echeckcredit.echeck = echeck;
            var billToAddress = new contact();

            billToAddress.name         = "Bob";
            billToAddress.city         = "Lowell";
            billToAddress.state        = "MA";
            billToAddress.email        = "cnp.com";
            echeckcredit.billToAddress = billToAddress;
            echeckcredit.id            = "id";

            cnpBatchRequest.addEcheckCredit(echeckcredit);

            var echeckcredit2 = new echeckCredit();

            echeckcredit2.amount      = 12L;
            echeckcredit2.orderId     = "12346";
            echeckcredit2.orderSource = orderSourceType.ecommerce;
            var echeck2 = new echeckType();

            echeck2.accType      = echeckAccountTypeEnum.Checking;
            echeck2.accNum       = "1099999903";
            echeck2.routingNum   = "011201995";
            echeck2.checkNum     = "123456";
            echeckcredit2.echeck = echeck2;
            var billToAddress2 = new contact();

            billToAddress2.name         = "Mike";
            billToAddress2.city         = "Lowell";
            billToAddress2.state        = "MA";
            billToAddress2.email        = "cnp.com";
            echeckcredit2.billToAddress = billToAddress2;
            echeckcredit2.id            = "id";

            cnpBatchRequest.addEcheckCredit(echeckcredit2);

            var echeckredeposit = new echeckRedeposit();

            echeckredeposit.cnpTxnId = 123456;
            echeckredeposit.echeck   = echeck;
            echeckredeposit.id       = "id";

            cnpBatchRequest.addEcheckRedeposit(echeckredeposit);

            var echeckredeposit2 = new echeckRedeposit();

            echeckredeposit2.cnpTxnId = 123457;
            echeckredeposit2.echeck   = echeck2;
            echeckredeposit2.id       = "id";

            cnpBatchRequest.addEcheckRedeposit(echeckredeposit2);

            var echeckSaleObj = new echeckSale();

            echeckSaleObj.amount        = 123456;
            echeckSaleObj.orderId       = "12345";
            echeckSaleObj.orderSource   = orderSourceType.ecommerce;
            echeckSaleObj.echeck        = echeck;
            echeckSaleObj.billToAddress = billToAddress;
            echeckSaleObj.id            = "id";

            cnpBatchRequest.addEcheckSale(echeckSaleObj);

            var echeckSaleObj2 = new echeckSale();

            echeckSaleObj2.amount        = 123456;
            echeckSaleObj2.orderId       = "12346";
            echeckSaleObj2.orderSource   = orderSourceType.ecommerce;
            echeckSaleObj2.echeck        = echeck2;
            echeckSaleObj2.billToAddress = billToAddress2;
            echeckSaleObj2.id            = "id";

            cnpBatchRequest.addEcheckSale(echeckSaleObj2);

            var echeckPreNoteSaleObj1 = new echeckPreNoteSale();

            echeckPreNoteSaleObj1.orderId       = "12345";
            echeckPreNoteSaleObj1.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteSaleObj1.echeck        = echeck;
            echeckPreNoteSaleObj1.billToAddress = billToAddress;
            echeckPreNoteSaleObj1.id            = "id";

            cnpBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleObj1);

            var echeckPreNoteSaleObj2 = new echeckPreNoteSale();

            echeckPreNoteSaleObj2.orderId       = "12345";
            echeckPreNoteSaleObj2.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteSaleObj2.echeck        = echeck2;
            echeckPreNoteSaleObj2.billToAddress = billToAddress2;
            echeckPreNoteSaleObj2.id            = "id";

            cnpBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleObj2);

            var echeckPreNoteCreditObj1 = new echeckPreNoteCredit();

            echeckPreNoteCreditObj1.orderId       = "12345";
            echeckPreNoteCreditObj1.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteCreditObj1.echeck        = echeck;
            echeckPreNoteCreditObj1.billToAddress = billToAddress;
            echeckPreNoteCreditObj1.id            = "id";

            cnpBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditObj1);

            var echeckPreNoteCreditObj2 = new echeckPreNoteCredit();

            echeckPreNoteCreditObj2.orderId       = "12345";
            echeckPreNoteCreditObj2.orderSource   = orderSourceType.ecommerce;
            echeckPreNoteCreditObj2.echeck        = echeck2;
            echeckPreNoteCreditObj2.billToAddress = billToAddress2;
            echeckPreNoteCreditObj2.id            = "id";

            var echeckVerificationObject = new echeckVerification();

            echeckVerificationObject.amount        = 123456;
            echeckVerificationObject.orderId       = "12345";
            echeckVerificationObject.orderSource   = orderSourceType.ecommerce;
            echeckVerificationObject.echeck        = echeck;
            echeckVerificationObject.billToAddress = billToAddress;
            echeckVerificationObject.id            = "id";

            cnpBatchRequest.addEcheckVerification(echeckVerificationObject);

            var echeckVerificationObject2 = new echeckVerification();

            echeckVerificationObject2.amount        = 123456;
            echeckVerificationObject2.orderId       = "12346";
            echeckVerificationObject2.orderSource   = orderSourceType.ecommerce;
            echeckVerificationObject2.echeck        = echeck2;
            echeckVerificationObject2.billToAddress = billToAddress2;
            echeckVerificationObject2.id            = "id";

            cnpBatchRequest.addEcheckVerification(echeckVerificationObject2);

            var forcecapture = new forceCapture();

            forcecapture.amount      = 106;
            forcecapture.orderId     = "12344";
            forcecapture.orderSource = orderSourceType.ecommerce;
            forcecapture.card        = card;
            forcecapture.id          = "id";

            cnpBatchRequest.addForceCapture(forcecapture);

            var forcecapture2 = new forceCapture();

            forcecapture2.amount      = 106;
            forcecapture2.orderId     = "12345";
            forcecapture2.orderSource = orderSourceType.ecommerce;
            forcecapture2.card        = card2;
            forcecapture2.id          = "id";

            cnpBatchRequest.addForceCapture(forcecapture2);

            var saleObj = new sale();

            saleObj.amount      = 106;
            saleObj.cnpTxnId    = 123456;
            saleObj.orderId     = "12344";
            saleObj.orderSource = orderSourceType.ecommerce;
            saleObj.card        = card;
            saleObj.id          = "id";

            cnpBatchRequest.addSale(saleObj);

            var saleObj2 = new sale();

            saleObj2.amount      = 106;
            saleObj2.cnpTxnId    = 123456;
            saleObj2.orderId     = "12345";
            saleObj2.orderSource = orderSourceType.ecommerce;
            saleObj2.card        = card2;
            saleObj2.id          = "id";

            cnpBatchRequest.addSale(saleObj2);

            var registerTokenRequest = new registerTokenRequestType();

            registerTokenRequest.orderId       = "12344";
            registerTokenRequest.accountNumber = "1233456789103801";
            registerTokenRequest.reportGroup   = "Planets";
            registerTokenRequest.id            = "id";

            cnpBatchRequest.addRegisterTokenRequest(registerTokenRequest);

            var registerTokenRequest2 = new registerTokenRequestType();

            registerTokenRequest2.orderId       = "12345";
            registerTokenRequest2.accountNumber = "1233456789103801";
            registerTokenRequest2.reportGroup   = "Planets";
            registerTokenRequest2.id            = "id";

            cnpBatchRequest.addRegisterTokenRequest(registerTokenRequest2);

            var updateCardValidationNumOnToken = new updateCardValidationNumOnToken();

            updateCardValidationNumOnToken.orderId           = "12344";
            updateCardValidationNumOnToken.cardValidationNum = "123";
            updateCardValidationNumOnToken.cnpToken          = "4100000000000001";
            updateCardValidationNumOnToken.id = "id";

            cnpBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken);

            var updateCardValidationNumOnToken2 = new updateCardValidationNumOnToken();

            updateCardValidationNumOnToken2.orderId           = "12345";
            updateCardValidationNumOnToken2.cardValidationNum = "123";
            updateCardValidationNumOnToken2.cnpToken          = "4242424242424242";
            updateCardValidationNumOnToken2.id = "id";

            cnpBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken2);

//            fastAccessFunding fastAccessFunding = new fastAccessFunding();
//            fastAccessFunding.id = "A123456";
//            fastAccessFunding.reportGroup = "FastPayment";
//            fastAccessFunding.fundingSubmerchantId = "SomeSubMerchant";
//            fastAccessFunding.submerchantName = "Some Merchant Inc.";
//            fastAccessFunding.fundsTransferId = "123e4567e89b12d3";
//            fastAccessFunding.amount = 3000;
//            fastAccessFunding.token = new cardTokenType
//            {
//                cnpToken = "1111000101039449",
//                expDate = "1112",
//                cardValidationNum = "987",
//                type = methodOfPaymentTypeEnum.VI,
//            };
//            cnpBatchRequest.addfastAccessFunding(fastAccessFunding);

            cnp.addBatch(cnpBatchRequest);

            var batchName = cnp.sendToCnp();

            cnp.blockAndWaitForResponse(batchName, estimatedResponseTime(2 * 2, 10 * 2));

            var cnpResponse = cnp.receiveFromCnp(batchName);

            Assert.NotNull(cnpResponse);
            Assert.AreEqual("0", cnpResponse.response);
            Assert.AreEqual("Valid Format", cnpResponse.message);

            var cnpBatchResponse = cnpResponse.nextBatchResponse();

            while (cnpBatchResponse != null)
            {
                var authorizationResponse = cnpBatchResponse.nextAuthorizationResponse();
                while (authorizationResponse != null)
                {
                    Assert.AreEqual("000", authorizationResponse.response);

                    authorizationResponse = cnpBatchResponse.nextAuthorizationResponse();
                }

                var authReversalResponse = cnpBatchResponse.nextAuthReversalResponse();
                while (authReversalResponse != null)
                {
                    Assert.AreEqual("000", authReversalResponse.response);

                    authReversalResponse = cnpBatchResponse.nextAuthReversalResponse();
                }

                var giftCardAuthReversalResponse = cnpBatchResponse.nextGiftCardAuthReversalResponse();
                while (giftCardAuthReversalResponse != null)
                {
                    Assert.NotNull(giftCardAuthReversalResponse.response);

                    giftCardAuthReversalResponse = cnpBatchResponse.nextGiftCardAuthReversalResponse();
                }

                var captureResponse = cnpBatchResponse.nextCaptureResponse();
                while (captureResponse != null)
                {
                    Assert.AreEqual("000", captureResponse.response);

                    captureResponse = cnpBatchResponse.nextCaptureResponse();
                }

                var giftCardCaptureResponse = cnpBatchResponse.nextGiftCardCaptureResponse();
                while (giftCardCaptureResponse != null)
                {
                    Assert.NotNull(giftCardCaptureResponse.response);

                    giftCardCaptureResponse = cnpBatchResponse.nextGiftCardCaptureResponse();
                }


                var captureGivenAuthResponse = cnpBatchResponse.nextCaptureGivenAuthResponse();
                while (captureGivenAuthResponse != null)
                {
                    Assert.AreEqual("000", captureGivenAuthResponse.response);

                    captureGivenAuthResponse = cnpBatchResponse.nextCaptureGivenAuthResponse();
                }

                var creditResponse = cnpBatchResponse.nextCreditResponse();
                while (creditResponse != null)
                {
                    Assert.AreEqual("000", creditResponse.response);

                    creditResponse = cnpBatchResponse.nextCreditResponse();
                }

                var giftCardCreditResponse = cnpBatchResponse.nextGiftCardCreditResponse();
                while (giftCardCreditResponse != null)
                {
                    Assert.NotNull(giftCardCreditResponse.response);

                    giftCardCreditResponse = cnpBatchResponse.nextGiftCardCreditResponse();
                }

                var echeckCreditResponse = cnpBatchResponse.nextEcheckCreditResponse();
                while (echeckCreditResponse != null)
                {
                    Assert.AreEqual("000", echeckCreditResponse.response);

                    echeckCreditResponse = cnpBatchResponse.nextEcheckCreditResponse();
                }

                var echeckRedepositResponse = cnpBatchResponse.nextEcheckRedepositResponse();
                while (echeckRedepositResponse != null)
                {
                    Assert.AreEqual("000", echeckRedepositResponse.response);

                    echeckRedepositResponse = cnpBatchResponse.nextEcheckRedepositResponse();
                }

                var echeckSalesResponse = cnpBatchResponse.nextEcheckSalesResponse();
                while (echeckSalesResponse != null)
                {
                    Assert.AreEqual("000", echeckSalesResponse.response);

                    echeckSalesResponse = cnpBatchResponse.nextEcheckSalesResponse();
                }

                var echeckPreNoteSaleResponse = cnpBatchResponse.nextEcheckPreNoteSaleResponse();
                while (echeckPreNoteSaleResponse != null)
                {
                    Assert.AreEqual("000", echeckPreNoteSaleResponse.response);

                    echeckPreNoteSaleResponse = cnpBatchResponse.nextEcheckPreNoteSaleResponse();
                }

                var echeckPreNoteCreditResponse = cnpBatchResponse.nextEcheckPreNoteCreditResponse();
                while (echeckPreNoteCreditResponse != null)
                {
                    Assert.AreEqual("000", echeckPreNoteCreditResponse.response);

                    echeckPreNoteCreditResponse = cnpBatchResponse.nextEcheckPreNoteCreditResponse();
                }

                var echeckVerificationResponse = cnpBatchResponse.nextEcheckVerificationResponse();
                while (echeckVerificationResponse != null)
                {
                    Assert.AreEqual("957", echeckVerificationResponse.response);

                    echeckVerificationResponse = cnpBatchResponse.nextEcheckVerificationResponse();
                }

                var forceCaptureResponse = cnpBatchResponse.nextForceCaptureResponse();
                while (forceCaptureResponse != null)
                {
                    Assert.AreEqual("000", forceCaptureResponse.response);

                    forceCaptureResponse = cnpBatchResponse.nextForceCaptureResponse();
                }

                var registerTokenResponse = cnpBatchResponse.nextRegisterTokenResponse();
                while (registerTokenResponse != null)
                {
                    Assert.AreEqual("820", registerTokenResponse.response);

                    registerTokenResponse = cnpBatchResponse.nextRegisterTokenResponse();
                }

                var saleResponse = cnpBatchResponse.nextSaleResponse();
                while (saleResponse != null)
                {
                    Assert.AreEqual("000", saleResponse.response);

                    saleResponse = cnpBatchResponse.nextSaleResponse();
                }

                var updateCardValidationNumOnTokenResponse = cnpBatchResponse.nextUpdateCardValidationNumOnTokenResponse();
                while (updateCardValidationNumOnTokenResponse != null)
                {
                    Assert.AreEqual("823", updateCardValidationNumOnTokenResponse.response);

                    updateCardValidationNumOnTokenResponse = cnpBatchResponse.nextUpdateCardValidationNumOnTokenResponse();
                }

                cnpBatchResponse = cnpResponse.nextBatchResponse();
            }
        }
Esempio n. 55
0
 AssertEquals(contact.id, "some id");
        public void test2Sale()
        {
            var sale = new sale();
            sale.orderId = "2";
            sale.amount = 20020;
            sale.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Mike J. Hammer";
            contact.addressLine1 = "2 Main St.";
            contact.addressLine2 = "Apt. 222";
            contact.city = "Riverside";
            contact.state = "RI";
            contact.zip = "02915";
            contact.country = countryTypeEnum.US;
            sale.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.MC;
            card.number = "5112010000000003";
            card.expDate = "0212";
            card.cardValidationNum = "261";
            sale.card = card;
            var authenticationvalue = new fraudCheckType();
            authenticationvalue.authenticationValue = "BwABBJQ1AgAAAAAgJDUCAAAAAAA=";
            sale.cardholderAuthentication = authenticationvalue;

            var response = litle.Sale(sale);
            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("22222", response.authCode);
            Assert.AreEqual("10", response.fraudResult.avsResult);
            Assert.AreEqual("M", response.fraudResult.cardValidationResult);

            var credit = new credit();
            credit.litleTxnId = response.litleTxnId;
            var creditResponse = litle.Credit(credit);
            Assert.AreEqual("000", creditResponse.response);
            Assert.AreEqual("Approved", creditResponse.message);

            var newvoid = new voidTxn();
            newvoid.litleTxnId = creditResponse.litleTxnId;
            var voidResponse = litle.DoVoid(newvoid);
            Assert.AreEqual("000", voidResponse.response);
            Assert.AreEqual("Approved", voidResponse.message);
        }
Esempio n. 57
0
 AssertEquals(contact.details.mail, "*****@*****.**");
        public void test3AVS()
        {
            var authorization = new authorization();
            authorization.orderId = "3";
            authorization.amount = 0;
            authorization.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Eileen Jones";
            contact.addressLine1 = "3 Main St.";
            contact.city = "Bloomfield";
            contact.state = "CT";
            contact.zip = "06002";
            contact.country = countryTypeEnum.US;
            authorization.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.DI;
            card.number = "6011010000000003";
            card.expDate = "0312";
            card.cardValidationNum = "758";
            authorization.card = card;

            var response = litle.Authorize(authorization);
            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("33333", response.authCode);
            Assert.AreEqual("10", response.fraudResult.avsResult);
            Assert.AreEqual("M", response.fraudResult.cardValidationResult);
        }
Esempio n. 59
0
    static void xmpp_OnPresence(object sender, Presence pres)
    {
        //Console.WriteLine("Available Contacts: ");
        //Console.WriteLine( pres.From.User+ " : " + pres.From.Server + " : "  + pres.Type);

        int count = 0;
        //check to see if we just update the pres
        while (contacts.Count != 0 &&  count < contacts.Count )
        {
            if(contacts.ElementAt(count).userID == pres.From.User)
            {
                contacts.ElementAt(count).status = pres.Type.ToString();
                return;
            }
            count++;
        }

        count = 0;
        //if now, we add to the list
        contact info = new contact();
        info.userID = pres.From.User;
        info.status = pres.Type.ToString();
        contacts.Add(info);
    }
        public void test3Sale()
        {
            var sale = new sale();
            sale.orderId = "3";
            sale.amount = 30030;
            sale.orderSource = orderSourceType.ecommerce;
            var contact = new contact();
            contact.name = "Eileen Jones";
            contact.addressLine1 = "3 Main St.";
            contact.city = "Bloomfield";
            contact.state = "CT";
            contact.zip = "06002";
            contact.country = countryTypeEnum.US;
            sale.billToAddress = contact;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.DI;
            card.number = "6011010000000003";
            card.expDate = "0312";
            card.cardValidationNum = "758";
            sale.card = card;

            var response = litle.Sale(sale);
            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("33333", response.authCode);
            Assert.AreEqual("10", response.fraudResult.avsResult);
            Assert.AreEqual("M", response.fraudResult.cardValidationResult);

            var credit = new credit();
            credit.litleTxnId = response.litleTxnId;
            var creditResponse = litle.Credit(credit);
            Assert.AreEqual("000", creditResponse.response);
            Assert.AreEqual("Approved", creditResponse.message);

            var newvoid = new voidTxn();
            newvoid.litleTxnId = creditResponse.litleTxnId;
            var voidResponse = litle.DoVoid(newvoid);
            Assert.AreEqual("000", voidResponse.response);
            Assert.AreEqual("Approved", voidResponse.message);
        }