public ActionResult QBDesktopDisconnect() { CoQuickBooks cqb = db.CoQuickBooks.Where(p => p.SiteCoID == siteusercompanyid).FirstOrDefault(); if (cqb != null) { string testAccesToken = Utility.Decrypt(Encoding.UTF8.GetString(cqb.AccessToken), skey); string st = DisconnectRealm(qbappKey, qbappSecret, testAccesToken, cqb.apiSecret); db.CoQuickBooks.Remove(cqb); db.SaveChanges(); } return(RedirectToAction("Index")); }
public QBAuthorizationdto IsTokenAvailable(object oauthController, int siteCoID) { var oAuthDetails = new QBAuthorizationdto(); using (var db = new ePontiv2Entities()) { CoQuickBooks currentIndex = db.CoQuickBooks.Where(p => p.SiteCoID == siteCoID).FirstOrDefault(); if (currentIndex != null) { string testAccesToken = Utility.Decrypt(Encoding.UTF8.GetString(currentIndex.AccessToken), oAuthDetails.SecurityKey); oAuthDetails.AccessToken = testAccesToken; oAuthDetails.AccessTokenSecret = currentIndex.apiSecret; oAuthDetails.IsConnected = true; oAuthDetails.DataSource = currentIndex.DataSource; oAuthDetails.Realmid = currentIndex.RealmID; Save(oauthController, oAuthDetails); } } return(oAuthDetails); }
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)); } }
// GET: Sections/People public ActionResult Index() { //ViewBag.Sorting = new string[] { "Last", "First", "Company" }; //ViewBag.Company=new SelectList(db.GetContactCompaniesBySiteCoID(siteusercompanyid).ToList(),nameof(GetContactCompaniesBySiteCoID_Result.ViewID), nameof(GetContactCompaniesBySiteCoID_Result.Company)); ViewBag.CompanyList = db.GetContactCompaniesBySiteCoID(siteusercompanyid).Where(s => s.Company != null && s.Company.Trim() != "").ToList(); //ViewBag.ContactType = new SelectList(db.CoContactTypes.Where(p => p.SiteCoID == siteusercompanyid).OrderBy(p => p.ContactTypeOrder), "ContactTypeID", "ContactTypeName"); ViewBag.ContactTypeList = db.CoContactTypes.Where(p => p.SiteCoID == siteusercompanyid).OrderBy(p => p.ContactTypeOrder).ToList(); 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); CoQuickBooks cqb = db.CoQuickBooks.Where(p => p.SiteCoID == siteusercompanyid).FirstOrDefault(); if (cqb != null) { ViewBag.IsConnected = true; } qbModels = new QBModels(); //var q = coContacts.Where(p => p.ContactManager == siteuserid); // ViewBag.TotalRecords = q.Count(); //ViewBag.CurrentPage = 1; // ViewBag.CurrentSort = "Last"; // ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(ViewBag.TotalRecords) / Convert.ToDouble(CommonCls.PageSize)); // List<CoContacts> listcontact = q.OrderBy(s=>s.ContactLastName).ToList(); //foreach (var item in listcontact) //{ // if (item.CoContactCompanies == null) // { // item.CoContactCompanies = new CoContactCompanies(); // } // if (item.CoContactTypes == null) // { // item.CoContactTypes = new CoContactTypes(); // } // if (item.CoContactSubtypes == null) // { // item.CoContactSubtypes = new CoContactSubtypes(); // } //} //List<ContactList> Contact = new List<ContactList>(); //Int64 Id = 0; //foreach (var C in listcontact) //{ // Id++; // ContactList Contact1 = new ContactList(); // Contact1.Id = Id; // Contact1.ContactFirstName = C.ContactFirstName; // Contact1.ContactLastName = C.ContactLastName; // Contact1.ContactCoName = C.CoContactCompanies.ContactCoName; // Contact1.ContactTypeName = C.CoContactTypes.ContactTypeName; // Contact1.SubtypeName = C.CoContactSubtypes.SubtypeName; // Contact.Add(Contact1); //} //ViewBag.ContactsList = Contact; //qbModels.coContacts = listcontact;//coContacts.Where(p=>p.ContactManager==siteuserid).ToList().ForEach(s=>s.CoContactCompanies==null ? s.CoContactCompanies = new CoContactCompanies() : s.CoContactCompanies = s.CoContactCompanies); 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)); } }