public async Task Update_Website_URL() { // var devAppConfigName = "SmartAgentDev"; var productionDatabase = "SmartAgentProd"; IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings[productionDatabase].ConnectionString); IKernel kernel = new StandardKernel(new RepoTestsModule(db)); var websiteRepo = kernel.Get <IAsyncRepository <WebsiteMaster> >(); var website = WebsiteMaster.CreateWebsiteMaster( "Allied Physicians Submit", "https://portal.nmm.cc/Portal", "CFC", new Guid("e6b9299a-f903-4120-a481-3e5952fb98bc"), 122 ); await websiteRepo.UpdateAsync(website); var websites = await websiteRepo.GetAllAsync(); var unitedHealthCare = websites.Where(site => site.WebsiteDomain == website.WebsiteDomain).FirstOrDefault(); Console.WriteLine(unitedHealthCare); }
public async Task Create_Website_Test() { Guid websitekey = Guid.NewGuid(); var container = new UnityContainer(); var websiteMaster = WebsiteMaster.CreateWebsiteMaster( "Emdeon Script", "http://portal.nmm.cc/nmm/en/index.jsp", "CFC", Guid.NewGuid(), 117 ); Func <WebsiteMaster, string, Task <Guid> > CreateWebsiteRecord = async(website, connectionString) => { using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings[connectionString].ConnectionString)) { container.RegisterType <ISmartAgentRepo, CreateSmartAgentUserRepo>(new InjectionConstructor(db)); var repo = container.Resolve <ISmartAgentRepo>(); return(await repo.CreateWebsiteMasterRecord(website)); } }; Func <string, string, Task <WebsiteMaster> > FindWebsiteRecord = async(searchTerm, connectionString) => { using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings[connectionString].ConnectionString)) { container.RegisterType <ISmartAgentRepo, CreateSmartAgentUserRepo>(new InjectionConstructor(db)); var repo = container.Resolve <ISmartAgentRepo>(); return(await repo.FindWebsiteRecord(searchTerm)); } }; var dataSource = _devSmartAgent; var prodDataSource = _prodSmartAgentDb; var result = await FindWebsiteRecord(websiteMaster.WebsiteDescription, dataSource); if (result == null) { websitekey = await CreateWebsiteRecord(websiteMaster, dataSource); write(websitekey); } write(result.WebsiteDescription + " " + result.WebsiteKey); var result2 = await FindWebsiteRecord(websiteMaster.WebsiteDescription, prodDataSource); if (result2 == null) { websitekey = await CreateWebsiteRecord(websiteMaster, prodDataSource); write(websitekey); } write(result.WebsiteDescription + " " + result.WebsiteKey); }
public async Task <Guid> CreateWebsiteMasterRecord(WebsiteMaster website) { if (String.IsNullOrWhiteSpace(website.WebsiteDescription)) { throw new ArgumentNullException("Need website description to process."); } var webSiteExsits = await CheckForWebsiteRecord(website.WebsiteDescription); if (webSiteExsits) { return(new Guid("00000000-0000-0000-0000-000000000000")); } var query = @"IF NOT EXISTS (SELECT websiteDescription FROM dsa_websiteMaster WHERE websiteDescription = @websiteDescription) BEGIN INSERT INTO [ScriptingAgentDatabase].dbo.dsa_websiteMaster( dateAdded,dateChanged,lastUserID, deviceID , websitekey , websiteDescription, websiteDomain, DontValidateHCPCS) VALUES (GetDate(),GetDate(), 'kris.lindsey' ,@deviceId ,@websiteKey ,@websiteDescription ,@websiteDomain ,0) SELECT websiteKey FROM [ScriptingAgentDatabase].dbo.dsa_websiteMaster WHERE websiteDescription = @websiteDescription END"; var p = new DynamicParameters(); p.Add("@deviceId", website.DeviceId); p.Add("@websiteDescription", website.WebsiteDescription); p.Add("@websiteDomain", website.WebsiteDomain); p.Add("@websiteKey", website.WebsiteKey); try { var websiteKey = await _db.QueryAsync <Guid>(query, p); return(websiteKey.SingleOrDefault()); } catch (SqlException) { throw; } }
public async Task Update_Website_Url_Test() { IDbConnection prodDb = new SqlConnection(ConfigurationManager.ConnectionStrings[_prodSmartAgentDb].ConnectionString); IDbConnection devDb = new SqlConnection(ConfigurationManager.ConnectionStrings[_devSmartAgent].ConnectionString); var uhc = WebsiteMaster.CreateWebsiteMaster( "Community Family Care", "https://www.capcms.com/capconnect/login.aspx", "CFC", Guid.NewGuid(), 101 ); var container = new UnityContainer(); container.RegisterType <IAsyncRepository <WebsiteMaster>, WebsiteMasterAsyncRepository>(new InjectionConstructor(devDb)); var repo = container.Resolve <IAsyncRepository <WebsiteMaster> >(); await repo.UpdateAsync(uhc); Console.WriteLine(); }
public async Task Create_Website() { Func <WebsiteMaster, string, Task <Guid> > CreateRecord = async(newRecord, dbConfig) => { using (IDbConnection smartAgentDb = new SqlConnection(ConfigurationManager.ConnectionStrings[dbConfig].ConnectionString)) { IKernel kernel = new StandardKernel(new RepoTestsModule(smartAgentDb)); var repo = kernel.Get <ISmartAgentRepo>(); return(await repo.CreateWebsiteMasterRecord(newRecord)); } }; var smartAgentDevelopmentDb = "SmartAgentDev"; var smartAgentProdDb = "SmartAgentProd"; var websitesToAdd = new List <WebsiteMaster>(); var website = WebsiteMaster.CreateWebsiteMaster( websiteDesription: "Maverick Medical Group Submit", websiteDoman: "https://aerial.carecoordination.medecision.com/pmg/physician/LoginDefault.aspx", deviceId: "MMG", websiteKey: Guid.NewGuid(), portalId: 3 ); websitesToAdd.Add(website); var result = await CreateRecord(website, smartAgentDevelopmentDb); Console.WriteLine(result); var prodResult = await CreateRecord(website, smartAgentProdDb); Console.WriteLine(prodResult); }