public ActionResult SessionFiles()
        {
            if (TempData["SaleztoolSyncMessage"] != null && TempData["SaleztoolSyncSuccess"] != null)
            {
                ViewBag.SyncSuccessMessage = TempData["SaleztoolSyncMessage"];
                ViewBag.IsSuccess          = TempData["SaleztoolSyncSuccess"];
                TempData.Remove("SaleztoolSyncSuccess");
                TempData.Remove("SaleztoolSyncMessage");
            }
            sTService             = new STServices(siteuserid);
            ViewBag.IsSTConnected = sTService.IsConnected(siteuserid);

            if (ViewBag.IsSTConnected == true)
            {
                List <STSessionModel> sessionList = sTService.GetSessions();
                ViewBag.SessionList = sessionList;
            }
            return(View());
        }
示例#2
0
        public ActionResult Index()
        {
            if (TempData["SyncSuccessMessage"] != null)
            {
                ViewBag.SyncSuccessMessage = TempData["SyncSuccessMessage"];
                TempData.Remove("SyncSuccessMessage");
            }
            sTService             = new STServices();
            ViewBag.IsDBConnected = false;
            ViewBag.IsQBConnected = false;
            ViewBag.IsSTConnected = sTService.IsConnected(siteuserid);

            CoDropbox drpconnection = db.CoDropbox.Where(p => p.SiteCoID == siteusercompanyid).FirstOrDefault();

            if (drpconnection != null)
            {
                ViewBag.IsDBConnected = true;
            }
            CoQuickBooks currentIndex = db.CoQuickBooks.Where(p => p.SiteCoID == siteusercompanyid).FirstOrDefault();

            if (currentIndex != null)
            {
                ViewBag.IsQBConnected = true;
            }
            ViewBag.ContactType = new SelectList(db.CoContactTypes.Where(p => p.SiteCoID == siteusercompanyid).OrderBy(p => p.ContactTypeOrder), "ContactTypeID", "ContactTypeName");
            int siteCoID   = base.siteusercompanyid;
            var coContacts = db.CoContacts
                             .Where(p => p.SiteCoID == siteCoID)
                             .Include(c => c.CoContactCompanies)
                             .Include(p => p.CoContactPhones)
                             .Include(p => p.CoContactEmails)
                             //.Include(c => c.CoContactSubtypes)
                             .Include(c => c.CoContactTypes)
                             .Include(c => c.SiteContactStatus)
                             .OrderBy(p => p.ContactLastName).ThenBy(p => p.ContactFirstName).ThenBy(p => p.CoContactCompanies.ContactCoName);

            qbModels                     = new QBModels();
            qbModels.coContacts          = coContacts.ToList();
            qbModels.SyncObjectsModel    = new QBSyncdto();
            qbModels.OAuthorizationModel = new QBAuthorizationdto();
            qbModels.IsReadySync         = false;
            var oAuthModel = new QBOAuthService(qbModels.OAuthorizationModel).IsTokenAvailable(this, siteCoID);

            if (oAuthModel.IsConnected)
            {
                qbModels.IsReadySync         = true;
                qbModels.OAuthorizationModel = oAuthModel;
                qbModels.IsConnected         = oAuthModel.IsConnected;
                var syncService = new QBSyncService(oAuthModel);
                qbModels.SyncObjectsModel.OauthToken = oAuthModel;
                //    qbModels.SyncObjectsModel = syncService.IsCustSync(qbModels.SyncObjectsModel, syncService, siteusercompanyid);
                qbModels.SyncObjectsModel.CompanyId = oAuthModel.Realmid;
                qbModels.SyncObjectsModel           = Save(this, qbModels.SyncObjectsModel);
                qbModels.IsReadyTimeentry           = qbModels.SyncObjectsModel.IsCustomerSync;
                qbModels.IsReadytoInvoice           = false;
                return(View(qbModels));
            }
            else
            {
                return(View(qbModels));
            }
        }