public async Task AddLaunchToProductAsync([Validate(true, 36, 36)] string productKey, Launch launch)
        {
            var keyValidation    = productKey.Validate();
            var launchValidation = launch.Validate();

            if (keyValidation.IsValid() && launchValidation.IsValid())
            {
                var product = await _repository.GetProductByKeyAsync(productKey);

                if (product != null)
                {
                    launch.Key = KeyBuilder.Build();

                    product.ModifiedOn = DateTime.Now;

                    product.Launches.Add(launch);

                    await _repository.UpdateProductAsync(product, productKey);

                    var args = new AddLaunchToProductEventArgs {
                        Launch = launch, ProductKey = productKey
                    };

                    LaunchAddedToProduct?.Invoke(this, args);
                }
            }
            else
            {
                throw new EntityException(keyValidation.Aggregate(launchValidation));
            }
        }
 public Domain.Entities.Person Map(CreatePersonModel source)
 {
     return(new Domain.Entities.Person
     {
         Age = source.Age,
         Key = KeyBuilder.Build(),
         Name = source.Name
     });
 }
Ejemplo n.º 3
0
        private void btnPull_Click(object sender, EventArgs e)
        {
            string host     = txtHost.Text.Trim();
            string database = txtDatabase.Text.Trim();
            string appKey   = txtAppKey.Text.Trim();

            string key = KeyBuilder.Build(host, database, appKey);

            MessageBox.Show(SecurityClient.Get(key));
        }
        public RequestFile Map(CreatePhotoRequest source)
        {
            if (source == null)
            {
                return(null);
            }

            return(new RequestFile
            {
                Key = KeyBuilder.Build(),
                ContentType = source.ContentType,
                Data = source.Data
            });
        }
        public Coin Map(CreateCoinRequest source)
        {
            if (source == null)
            {
                return(null);
            }

            return(new Coin
            {
                Key = KeyBuilder.Build(),
                Country = source.Country,
                Name = source.Name,
                Reference = source.Reference
            });
        }
Ejemplo n.º 6
0
        public async Task CreatePersonAsyncTest()
        {
            var person = Builder <Domain.Entities.Person>
                         .CreateNew()
                         .With(p => p.Key = KeyBuilder.Build())
                         .Build();

            await _repository.CreatePersonAsync(person);

            var persistedPerson = await _repository.GetPersonByKeyAsync(person.Key);

            Assert.Equal(person.Key, persistedPerson.Key);
            Assert.Equal(person.Name, persistedPerson.Name);
            Assert.Equal(person.Age, persistedPerson.Age);
        }
        public Price Map(CreatePriceRequest source)
        {
            if (source == null)
            {
                return(null);
            }

            var coin = _coinMapper.Map(source.Coin);

            return(new Price
            {
                Key = KeyBuilder.Build(),
                Coin = coin,
                Value = source.Value
            });
        }
Ejemplo n.º 8
0
        private void btnPush_Click(object sender, EventArgs e)
        {
            try
            {
                string host     = txtHost.Text.Trim();
                string database = txtDatabase.Text.Trim();
                string appKey   = txtAppKey.Text.Trim();
                string username = txtUsername.Text.Trim();
                string password = txtPassword.Text.Trim();

                string key = KeyBuilder.Build(host, database, appKey);
                SecurityClient.Add(key, string.Format("{0},{1}", username, password));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public Launch Map(CreateLaunchRequest source)
        {
            if (source == null)
            {
                return(null);
            }

            var coin = _coinMapper.Map(source.Coin);

            return(new Launch
            {
                Key = KeyBuilder.Build(),
                Type = source.Type,
                Value = source.Value,
                ValueType = source.ValueType,
                IsAvailable = true,
                Coin = coin
            });
        }
Ejemplo n.º 10
0
        private static string CreateQuery()
        {
            Persons.ForEach(p => p.Key = KeyBuilder.Build());

            var values = Persons
                         .Select(p => $"('{KeyBuilder.Build()}', '{p.Name}', {p.Age})");

            var query = $@"

            INSERT INTO Person.Persons

            (Persons.Key, Persons.Name, Persons.Age)

            VALUES
            
            {string.Join(',', values)}
            ";

            return(query);
        }
Ejemplo n.º 11
0
        public ProductEntity Map(CreateProductRequest source)
        {
            if (source == null)
            {
                return(null);
            }

            var properties = source?.Properties?.Select(p => _propertyMapper.Map(p)).ToList();
            var launches   = source?.Launches?.Select(l => _launchMapper.Map(l)).ToList();
            var price      = _priceMapper.Map(source.Price);

            return(new ProductEntity
            {
                Key = KeyBuilder.Build(),
                Code = source.Code,
                Name = source.Name,
                Properties = properties,
                Launches = launches,
                Price = price,
                IsEnabled = true
            });
        }