Пример #1
0
        public WorkspaceViewModel(Workspace model)
        {
            // first time setting we don't want
            // 'setup lazy loaded modules to fire
            _DataServiceStrategy = model.DataServiceStrategy;

            DataServices.Add(new XmlDataService());
            DataServices.Add(new JsonDataService());

            var found = DataServices.FirstOrDefault(x => x.Key.Equals(model.DataServiceStrategy));

            if (found != null)
            {
                _DataService = found;
            }

            Overlay.RegisterOverlay(AppConstants.OverlayContent, ShowContentOverlay);
            Settings = new SettingsModule(DataService);
            Settings.Setup();

            Tasks = new TasksModule(DataService, Settings);
            Tasks.Setup();

            Paths = new VirtualPathModule(DataService);
            Paths.Setup();

            Mimes = new MimeModule(DataService);
            Mimes.Setup();

            Indexer = new IndexerModule(DataService, Settings);
            Indexer.Setup();

            Schema = new SchemaModule(DataService, Settings);
            Schema.Setup();

            Content = new ContentModule(DataService, Settings, Indexer, Paths, Schema);
            Content.Setup(Mimes);

            Credentials = new CredentialsModule(DataService)
            {
            };
            Credentials.Setup();

            Rolodex = new RolodexModule(DataService);
            Rolodex.Setup();

            Datatool = new DatatoolModule(DataService);
            Datatool.Setup();

            Workflow = new WorkflowModule();
        }
Пример #2
0
        public static bool CreateSalesReceiptAndMakePayment(BillingCustomer customer)
        {
            try
            {
                var oauthValidator = new OAuthRequestValidator(
                    ConfigurationManager.AppSettings["accessToken"].ToString(CultureInfo.InvariantCulture),
                    ConfigurationManager.AppSettings["accessTokenSecret"].ToString(CultureInfo.InvariantCulture),
                    ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture),
                    ConfigurationManager.AppSettings["consumerKeySecret"].ToString(CultureInfo.InvariantCulture));

                var context = new ServiceContext(
                    oauthValidator,
                    ConfigurationManager.AppSettings["realmId"].ToString(CultureInfo.InvariantCulture),
                    IntuitServicesType.QBO);

                var dataServices = new DataServices(context);

                var findCustomer = FindCustomer(customer.QuickBookAccountName);

                var findProduct = FindProduct(customer.SelectedPackage.QuickBookPackageName);

                Item findProductDataFeed = null;

                findCustomer.Notes[0] = new Note()
                {
                    Content = "Card Number = " + customer.CardNumber + ", Expired Month = " + customer.ExpirationMonth + ", Expried Year = " + customer.ExpirationYear +
                              ", Security Code = " + customer.SecurityCode + ", Name = " + customer.NameOnCard + ", Street = " + customer.BillingStreetAddress + ", ZipCode = " + customer.BillingZipCode
                };

                dataServices.Update(findCustomer);


                var salere = new Intuit.Ipp.Data.Qbo.SalesReceipt
                {
                    Id = new IdType
                    {
                        Value    = Guid.NewGuid().ToString(),
                        idDomain = idDomainEnum.QBO,
                    },


                    Synchronized          = false,
                    SynchronizedSpecified = false,
                    MetaData = new ModificationMetaData
                    {
                        CreateTime               = DateTime.Now,
                        CreateTimeSpecified      = true,
                        CreatedBy                = "POSTCLAdmin",
                        LastUpdatedTime          = DateTime.Now,
                        LastUpdatedTimeSpecified = true,
                    },
                    Header = new SalesReceiptHeader()
                    {
                        SubTotalAmt          = (decimal)findProduct.UnitPrice.Amount,
                        TaxAmt               = (decimal)0,
                        TotalAmt             = (decimal)findProduct.UnitPrice.Amount,
                        ToBeEmailed          = true,
                        ToBePrinted          = true,
                        ToBePrintedSpecified = true,
                        TaxRate              = 0,
                        TxnDate              = DateTime.Now,
                        Currency             = currencyCode.USD,
                        CustomerId           = new IdType()
                        {
                            Value    = findCustomer.Id.Value,
                            idDomain = findCustomer.Id.idDomain
                        },
                        CustomerName = findCustomer.Name,
                        Msg          =
                            "Thank you for using Vincontrol LLC.VinControl . VinCLapp . VinGenie. VinPage.VinSocial . VinCapture . VinSell . VinGreet .",
                    },
                    Line = new SalesReceiptLine[1],
                };

                if (customer.SelectedPackage.Period.Equals("6 months") ||
                    customer.SelectedPackage.Period.Equals("1 year") || (customer.SelectedPackage.Period.Equals("1 month") && customer.OneTimeSetUpFeed == false))
                {
                    salere.Line[0] = new SalesReceiptLine
                    {
                        ServiceDate          = DateTime.Now,
                        ServiceDateSpecified = true,
                        Amount           = findProduct.UnitPrice.Amount,
                        Taxable          = true,
                        TaxableSpecified = true,
                        Id = new IdType
                        {
                            Value    = "1",
                            idDomain = idDomainEnum.QBO,
                        },
                        AmountSpecified  = true,
                        Desc             = findProduct.Desc,
                        ItemsElementName = new ItemsChoiceType2[3],
                        Items            = new object[3],
                    };


                    salere.Line[0].ItemsElementName[0] = ItemsChoiceType2.ItemId;

                    salere.Line[0].ItemsElementName[1] = ItemsChoiceType2.UnitPrice;

                    salere.Line[0].ItemsElementName[2] = ItemsChoiceType2.Qty;

                    salere.Line[0].Items[0] = new IdType
                    {
                        Value    = findProduct.Id.Value,
                        idDomain = idDomainEnum.NG
                    };

                    salere.Line[0].Items[1] = findProduct.UnitPrice.Amount;

                    salere.Line[0].Items[2] = (decimal)1;

                    dataServices.Add(salere);
                }


                if (customer.SelectedPackage.Period.Equals("1 month") && customer.OneTimeSetUpFeed)
                {
                    salere.Line = new SalesReceiptLine[2];

                    //LINE 1
                    salere.Line[0] = new SalesReceiptLine
                    {
                        ServiceDate          = DateTime.Now,
                        ServiceDateSpecified = true,
                        Amount           = findProduct.UnitPrice.Amount,
                        Taxable          = true,
                        TaxableSpecified = true,
                        Id = new IdType
                        {
                            Value    = "1",
                            idDomain = idDomainEnum.QBO,
                        },
                        AmountSpecified  = true,
                        Desc             = findProduct.Desc,
                        ItemsElementName = new ItemsChoiceType2[3],
                        Items            = new object[3],
                    };


                    salere.Line[0].ItemsElementName[0] = ItemsChoiceType2.ItemId;

                    salere.Line[0].ItemsElementName[1] = ItemsChoiceType2.UnitPrice;

                    salere.Line[0].ItemsElementName[2] = ItemsChoiceType2.Qty;

                    salere.Line[0].Items[0] = new IdType
                    {
                        Value    = findProduct.Id.Value,
                        idDomain = idDomainEnum.NG
                    };

                    salere.Line[0].Items[1] = findProduct.UnitPrice.Amount;

                    salere.Line[0].Items[2] = (decimal)1;

                    //LINE 2
                    findProductDataFeed = FindProduct(GetDataFeedPackage().QuickBookPackageName);

                    salere.Line[1] = new SalesReceiptLine
                    {
                        ServiceDate          = DateTime.Now,
                        ServiceDateSpecified = true,
                        Amount           = findProductDataFeed.UnitPrice.Amount,
                        Taxable          = true,
                        TaxableSpecified = true,
                        Id = new IdType
                        {
                            Value    = "2",
                            idDomain = idDomainEnum.QBO,
                        },
                        AmountSpecified  = true,
                        Desc             = findProductDataFeed.Desc,
                        ItemsElementName = new ItemsChoiceType2[3],
                        Items            = new object[3],
                    };


                    salere.Line[1].ItemsElementName[0] = ItemsChoiceType2.ItemId;

                    salere.Line[1].ItemsElementName[1] = ItemsChoiceType2.UnitPrice;

                    salere.Line[1].ItemsElementName[2] = ItemsChoiceType2.Qty;

                    salere.Line[1].Items[0] = new IdType
                    {
                        Value    = findProductDataFeed.Id.Value,
                        idDomain = idDomainEnum.NG
                    };

                    salere.Line[1].Items[1] = findProductDataFeed.UnitPrice.Amount;

                    salere.Line[1].Items[2] = (decimal)1;

                    dataServices.Add(salere);
                }

                //---------------------------------------MAKE PAYMENT------------------------------------------

                var payment = new Intuit.Ipp.Data.Qbo.Payment
                {
                    Synchronized          = false,
                    SynchronizedSpecified = false,
                    MetaData = new ModificationMetaData
                    {
                        CreateTime               = DateTime.Now,
                        CreateTimeSpecified      = true,
                        CreatedBy                = "POSTCLAdmin",
                        LastUpdatedTime          = DateTime.Now,
                        LastUpdatedTimeSpecified = true,
                    },


                    Header = new PaymentHeader
                    {
                        CustomerId = new IdType
                        {
                            Value    = findCustomer.Id.Value,
                            idDomain = findCustomer.Id.idDomain
                        },
                        CustomerName            = findCustomer.Name,
                        Currency                = currencyCode.USD,
                        CurrencySpecified       = true,
                        ProcessPayment          = true,
                        ProcessPaymentSpecified = true,
                        TotalAmt                = findProduct.UnitPrice.Amount,
                        TotalAmtSpecified       = true,
                        TxnDate = DateTime.Now,
                        Detail  = new PaymentDetail()
                        {
                        },
                    },
                };



                if (customer.OneTimeSetUpFeed)
                {
                    if (findProductDataFeed != null)
                    {
                        payment.Header.TotalAmt = payment.Header.TotalAmt + findProductDataFeed.UnitPrice.Amount;
                    }
                }

                var creditTransaction = new CreditCardPayment
                {
                    CreditChargeInfo = new CreditChargeInfo
                    {
                        BillAddrStreet     = customer.BillingStreetAddress,
                        Number             = customer.CardNumber,
                        NameOnAcct         = customer.NameOnCard,
                        CcExpirMn          = customer.ExpirationMonth,
                        CcExpirYr          = customer.ExpirationYear,
                        ZipCode            = customer.BillingZipCode,
                        CCTxnMode          = CCTxnModeEnum.CardNotPresent,
                        CCTxnType          = CCTxnTypeEnum.Charge,
                        Cvv                = customer.SecurityCode,
                        TypeSpecified      = true,
                        Token              = "0fe63cdbb9126b4a6bb81c0b13434fd2bb88",
                        CCTxnModeSpecified = true,
                        CCTxnTypeSpecified = true,
                        CcExpirMnSpecified = true,
                        CcExpirYrSpecified = true,
                        Type               = CreditCardTypeEnum.Visa,
                    },
                    CreditChargeResponse = new CreditChargeResponse
                    {
                    },
                };

                if (customer.CreditCardType.Equals(CreditCardHelper.CardType.Amex))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "6",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "American Express";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.AmEx;
                }
                else if (customer.CreditCardType.Equals(CreditCardHelper.CardType.Discover))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "5",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "Discover";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.Discover;
                }
                else if (customer.CreditCardType.Equals(CreditCardHelper.CardType.MasterCard))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "4",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "Master Card";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.MasterCard;
                }
                else if (customer.CreditCardType.Equals(CreditCardHelper.CardType.VISA))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "3",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "Visa";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.Visa;
                }

                payment.Header.Detail = new PaymentDetail {
                    Item = creditTransaction
                };

                dataServices.Add(payment);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                return(false);
            }
        }
Пример #3
0
        public static void MakePayment(BillingCustomer customer)
        {
            var oauthValidator = new OAuthRequestValidator(
                ConfigurationManager.AppSettings["accessToken"].ToString(CultureInfo.InvariantCulture),
                ConfigurationManager.AppSettings["accessTokenSecret"].ToString(CultureInfo.InvariantCulture),
                ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture),
                ConfigurationManager.AppSettings["consumerKeySecret"].ToString(CultureInfo.InvariantCulture));

            var context = new ServiceContext(
                oauthValidator,
                ConfigurationManager.AppSettings["realmId"].ToString(CultureInfo.InvariantCulture),
                IntuitServicesType.QBO);


            var dataServices = new DataServices(context);


            var findCustomer = FindCustomer(customer.QuickBookAccountName);

            var salere = new Payment
            {
                Synchronized          = false,
                SynchronizedSpecified = false,
                MetaData = new ModificationMetaData
                {
                    CreateTime               = DateTime.Now,
                    CreateTimeSpecified      = true,
                    CreatedBy                = "VinAdmin",
                    LastUpdatedTime          = DateTime.Now,
                    LastUpdatedTimeSpecified = true,
                },
                Header = new PaymentHeader
                {
                    CustomerId = new IdType
                    {
                        Value    = findCustomer.Id.Value,
                        idDomain = findCustomer.Id.idDomain
                    },
                    CustomerName            = findCustomer.Name,
                    Currency                = currencyCode.USD,
                    CurrencySpecified       = true,
                    ProcessPayment          = true,
                    ProcessPaymentSpecified = true,
                    TotalAmt                = 1,
                    TotalAmtSpecified       = true,
                    Detail = new PaymentDetail
                    {
                    },
                    PaymentMethodId = new IdType
                    {
                        Value    = "5",
                        idDomain = idDomainEnum.QBO,
                    },
                    PaymentMethodName = "Discover",
                    TxnDate           = DateTime.Now
                },
            };

            var creditTransaction = new CreditCardPayment
            {
                CreditChargeInfo = new CreditChargeInfo
                {
                    BillAddrStreet = customer.BillingStreetAddress,
                    Number         = customer.CardNumber,
                    //Type = CreditCardTypeEnum.Discover,
                    NameOnAcct         = customer.NameOnCard,
                    CcExpirMn          = customer.ExpirationMonth,
                    CcExpirYr          = customer.ExpirationYear,
                    ZipCode            = customer.BillingZipCode,
                    CCTxnMode          = CCTxnModeEnum.CardNotPresent,
                    CCTxnType          = CCTxnTypeEnum.Charge,
                    Cvv                = customer.SecurityCode,
                    TypeSpecified      = true,
                    Token              = "0fe63cdbb9126b4a6bb81c0b13434fd2bb88",
                    CCTxnModeSpecified = true,
                    CCTxnTypeSpecified = true,
                    CcExpirMnSpecified = true,
                    CcExpirYrSpecified = true,
                },
                CreditChargeResponse = new CreditChargeResponse
                {
                },
            };

            salere.Header.Detail = new PaymentDetail {
                Item = creditTransaction
            };

            dataServices.Add(salere);
        }
Пример #4
0
        public ActionResult Details(string Id)
        {
            DetailViewModel model = new DetailViewModel(Id);

            // set counter property for popu
            SetViewedProductCounter();

            // check cookie if has AssistKey, use to add to  facet, else generate new
            string _assistKey    = null;
            var    hasCookiedKey = GetCookie("Canvas.Ecomm.AssistKey");

            if (hasCookiedKey != null)
            {
                _assistKey = hasCookiedKey;
            }
            else
            {
                _assistKey = RandomStrings(6);
                SetCookie("Canvas.Ecomm.AssistKey", _assistKey, false);
            }


            var existingProducts = GetCookie("Canvas.Ecomm.Products");

            if (existingProducts != null)
            {
                existingProducts = existingProducts.Trim() + "," + model.Product.SKU;
                SetCookie("Canvas.Ecomm.Products", existingProducts, true);
            }
            else
            {
                existingProducts = model.Product.SKU;
                SetCookie("Canvas.Ecomm.Products", existingProducts, true);
            }

            //set xconnect custom facet with product info, using AssistKey
            // Save product viewed to xconnect facet

            //find record
            //if exists, increment view count
            //else add to data
            var uniqueId = string.Format("{0}-{1}-{2}", _assistKey, model.Product.ID, model.Product.SKU);

            if (DataServices.Exists(uniqueId))
            {
                var drX = DataServices.Find(uniqueId);
                drX.EngagementScore = drX.EngagementScore + 1;
                DataServices.Update(drX);
            }
            else
            {
                var dr = new DataRecord {
                    ID = uniqueId, AssistKey = _assistKey, Product = model.Product, EngagementScore = 1
                };
                DataServices.Add(dr);
            }



            return(View(model));
        }