private void TestCm() { List <Sync.BL.Entities.List> cmList; this.Dispatcher.Invoke((Action)(() => { cmSettings = new CMSettings() { UserName = CMUserName.Text, Password = CMPassword.Password, ApiKey = CMApiKey.Text }; })); try { cmRepo = new CMRepository(cmSettings); Client cmClient = cmRepo.GetClients().FirstOrDefault(); cmList = cmRepo.GetLists(cmClient.ClientId); this.Dispatcher.Invoke((Action)(() => { MessageBox.Show(Application.Current.MainWindow, "Connection is OK"); TestingScreen.Visibility = System.Windows.Visibility.Hidden; })); } catch { this.Dispatcher.Invoke((Action)(() => { MessageBox.Show(Application.Current.MainWindow, "Test failed!"); TestingScreen.Visibility = System.Windows.Visibility.Hidden; })); } }
public void AddSubscribersTest() { CMSettings settings = new CMSettings(); settings.ApiKey = "4a087dfc720e09d91e8cb5cae9db51d5"; //Hard Coded ICMRepository repo = new CMRepository(settings); List <Client> clientList = repo.GetClients(); List <List> list = repo.GetLists(clientList.Find(x => x.Name == "Hal").ClientId.ToString()); //Create Test Subscribers List <Subscriber> importSubscribers = new List <Subscriber>() { new Subscriber() { E_mail = "*****@*****.**", Name = "Joze" }, new Subscriber() { E_mail = "*****@*****.**", Name = "Miha" }, new Subscriber() { E_mail = "*****@*****.**", Name = "Mojca" } }; //Import Subscribers repo.AddSubscribers(list.Find(x => x.Name == "Crm").ListId.ToString(), importSubscribers); //Test inported subscribers List <Subscriber> subscribers = repo.GetAciveSubscribers(list.Find(x => x.Name == "Crm").ListId.ToString()); Assert.IsNotNull(subscribers.Find(x => x.E_mail == "*****@*****.**")); }
public IQueryable <ContactDTO> GetAllContacts() { using (CMRepository repo = new CMRepository()) { return(repo.GetAllContacts()); } }
public SaveChangeEnum DeleteContact(int Id) { using (CMRepository repo = new CMRepository()) { return(repo.DeleteContact(Id)); } }
public SaveChangeEnum UpdateContact(ContactDTO _ContactDTO) { using (CMRepository repo = new CMRepository()) { return(repo.UpdateContact(_ContactDTO)); } }
public ContactDTO GetContactById(int Id) { using (CMRepository repo = new CMRepository()) { return(repo.GetContactById(Id)); } }
private void InitializeRepository() { cmSettings = ConnectionSettingsManager.GetCMSettings(); cmRepo = new CMRepository(cmSettings); crmSettings = ConnectionSettingsManager.GetCRMSettings(); crmRepo = new CRMRepository(crmSettings); }
public void ClientsTest() { CMSettings settings = new CMSettings(); settings.ApiKey = "4a087dfc720e09d91e8cb5cae9db51d5"; //Hard Coded ICMRepository repo = new CMRepository(settings); List <Client> list = repo.GetClients(); Assert.IsNotNull(list.Find(x => x.Name == "Hal")); }
public void UnsubscribedSubscribersTest() { CMSettings settings = new CMSettings(); settings.ApiKey = "4a087dfc720e09d91e8cb5cae9db51d5"; //Hard Coded ICMRepository repo = new CMRepository(settings); List <Client> clientList = repo.GetClients(); List <List> list = repo.GetLists(clientList.Find(x => x.Name == "Hal").ClientId.ToString()); List <Subscriber> subscribers = repo.GetUnsubscribedSubscribers(list.Find(x => x.Name == "Crm").ListId.ToString()); Assert.IsNull(subscribers.Find(x => x.Name == "Xxxxx Yyyyy")); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { try { var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>(); ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } if (!user.IsActive) { context.SetError("invalid_grant", "Error logging in user."); return; } var roles = userManager.GetRoles(user.Id); ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, OAuthDefaults.AuthenticationType); ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, CookieAuthenticationDefaults.AuthenticationType); // Find a matching UserProfile record for this user. var dataContextFactory = new CMDataContextFactory(); var dataContext = dataContextFactory.Create(); ICMRepository repository = new CMRepository(dataContext); var userProfileRecord = repository.CMDataContext.UserProfiles.SingleOrDefault(x => x.AspNetUsersId == user.Id); if (userProfileRecord != null) { // Add custom userProfileId claim to identity. var userProfileIdClaim = new Claim(Consts.CLAIM_USERPROFILEID, userProfileRecord.UserProfileId.ToString()); oAuthIdentity.AddClaim(userProfileIdClaim); cookiesIdentity.AddClaim(userProfileIdClaim); } // Populate the UserProfileId into the ticket as well. AuthenticationProperties properties = CreateProperties(user.UserName, user.Id, roles, userProfileRecord); AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); context.Validated(ticket); context.Request.Context.Authentication.SignIn(cookiesIdentity); } catch (Exception ex) { context.SetError("Critical Error", "Critical Error logging in"); Console.WriteLine(ex.Message); } }
public void ActiveSubscribersByTimeTest() { CMSettings settings = new CMSettings(); settings.ApiKey = "4a087dfc720e09d91e8cb5cae9db51d5"; //Hard Coded ICMRepository repo = new CMRepository(settings); List <Client> clientList = repo.GetClients(); List <List> list = repo.GetLists(clientList.Find(x => x.Name == "Hal").ClientId.ToString()); List <Subscriber> subscribers = repo.GetAciveSubscribers(list.Find(x => x.Name == "Crm").ListId.ToString(), DateTime.Now.AddHours(-1)); repo.GetAciveSubscribers(ListId: "dsds", fromDate: DateTime.Now); Assert.IsNotNull(subscribers.Find(x => x.Name == "Xxxxx Yyyyy")); }
//Read from register (instalation path, connection settings) private void Initialization() { cmSettings = ConnectionSettingsManager.GetCMSettings(); crmSettings = ConnectionSettingsManager.GetCRMSettings(); try { cmRepo = new CMRepository(cmSettings); crmRepo = new CRMRepository(crmSettings); } catch (Exception) { EventLogManager.WriteMessage(new Message() { Description = "Connection settings error", Type = "Error", Time = DateTime.Now }, EventType.Error); } }