public IActionResult Get([FromRoute] int id)
        {
            var model = _repoConfiguration.Get(id);

            if (model == null)
            {
                return(NotFound());
            }
            return(Ok(model));
        }
Beispiel #2
0
        private static void TriggerAlerts(string source, string target, Models.Rate rate90, Models.Rate rate4, Models.Rate rateRsi, Models.Rate last)
        {
            MessengerMessageSender  sender     = new MessengerMessageSender(new JsonMessengerSerializer());
            ConfigurationRepository repository = new ConfigurationRepository();

            //if (rateRsi.Value < 30)
            {
                var configs = repository.Get().Result;
                foreach (var config in configs)
                {
                    if (config.Source == source && config.Target == target)
                    {
                        var userId    = config.FacebookId;
                        var recipient = new MessengerUser();
                        recipient.Id = userId;
                        var configId = config.Id.ToString();
                        var response = new MessengerMessage();
                        response.Attachment         = new MessengerAttachment();
                        response.Attachment.Type    = "template";
                        response.Attachment.Payload = new MessengerPayload();
                        response.Attachment.Payload.TemplateType = "button";
                        response.Attachment.Payload.Text         = $"hi, we have found a good rate for your transfer: {source} to {target} is now {last.Value}. Tap the button below to do the transfer";
                        response.Attachment.Payload.Buttons      = new List <MessengerButton>();
                        var linkButton = new MessengerButton();
                        linkButton.Url   = $"https://transfer-buddy.herokuapp.com/Transfers/Create?configId={config.Id}";
                        linkButton.Title = "Transfer";
                        linkButton.Type  = "web_url";
                        response.Attachment.Payload.Buttons.Add(linkButton);
                        sender.SendAsync(response, recipient, "EAAaZCDGRPBJ4BAMVFRSRvqM8ytvC6ZAZCryE6xw5GImYZByvVpkIDhSpltas8CuclkcqZClTneXVzwMQqTeZCS5Gs3lf0sCLpiy977fg6bkGuNEESUysoPKKeJNGuW9WDZARKRw45J14A9BcustEzBsIvmbrUZCtVgZAohzKtG0w5DgZDZD").Wait();
                    }
                }
            }
        }
Beispiel #3
0
        public void Get()
        {
            // Arrange
            ConfigurationRepository repository = new ConfigurationRepository();

            // Act
            Configuration result = repository.Get("host1");

            // Assert
            Assert.IsNotNull(result);

            Assert.IsNotNull(result.hostname);

            Assert.AreEqual(result.name, "host1");
        }
 public Configuration Get(int id)
 {
     return(_configRepository.Get(id));
 }
Beispiel #5
0
        public void UpdateProfile(Guid UserId, UpdateProfileCommand command, string userName)
        {
            AssertConcern.AssertArgumentNotGuidEmpty(UserId, "Usuário inválido");

            var profile = ProfileRepository.GetByUserId(UserId.ToString());

            if (profile == null)
            {
                var genre      = (TypePerson)command.Genre;
                var newProfile = new Profile(UserId.ToString(), genre);
                newProfile.GenerateNewId();
                newProfile.Genre                 = genre;
                newProfile.MaritalStatus         = (MaritalStatus)command.MaritalStatus;
                newProfile.ZipCode               = command.ZipCode;
                newProfile.MaritalStatusInterest = (MaritalStatus)command.MaritalStatusInterest;
                newProfile.Summary               = command.Summary;

                ProfileRepository.Save(newProfile, userName);
            }
            else
            {
                AssertConcern.AssertArgumentNotNull(profile, "Perfil não encontrado");
                AssertConcern.AssertArgumentNotNull(profile.UserId, "Usuário não encontrado");
                profile.Genre                 = (TypePerson)command.Genre;
                profile.MaritalStatus         = (MaritalStatus)command.MaritalStatus;
                profile.ZipCode               = profile.ZipCode;
                profile.MaritalStatusInterest = (MaritalStatus)command.MaritalStatusInterest;
                profile.Summary               = command.Summary;
                ProfileRepository.Update(profile, userName);
            }

            if (command.Interests != null && command.Interests.Count > 0)
            {
                foreach (var item in command.Interests)
                {
                    var configuration = ConfigurationRepository.Get(item.UserId, item.Key);
                    if (configuration == null)
                    {
                        ConfigurationRepository.Create(item);
                    }

                    else
                    {
                        configuration.Value = item.Value;
                        ConfigurationRepository.Update(configuration);
                    }
                }
            }

            if (command.Relationships != null && command.Relationships.Count > 0)
            {
                foreach (var item in command.Relationships)
                {
                    var configuration = ConfigurationRepository.Get(item.UserId, item.Key);
                    if (configuration == null)
                    {
                        ConfigurationRepository.Create(item);
                    }
                    else
                    {
                        configuration.Value = item.Value;
                        ConfigurationRepository.Update(configuration);
                    }
                }
            }

            Uow.Commit();
        }