// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // mock data var random = new Random(); var customerHydrator = new Hydrator <Customer>() .With(x => x.Address, new Hydrator <Address>()) .With(x => x.BirthDate, new BirthDateGenerator()) .With(x => x.Active, new ActiveGenerator()); var customers = customerHydrator.GetList(1000); services.AddSingleton(customers); // autumn.mvc configuration services .AddAutumn(options => options // ?search=[RSQL query] .QueryFieldName("Search") // snake_case "Search" convert to "search" .NamingStrategy(new SnakeCaseNamingStrategy()) .HostingEnvironment(HostingEnvironment)) .AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "api", Version = "v1" }); c.OperationFilter <SwaggerOperationFilter>(); }) .AddMvc(); }
public FriendRepository() { //install-package objectHydrator //Sirve para rellenar de datos clases Default Hydrator <Friend> _friendHydrator = new Hydrator <Friend>(); Friends = _friendHydrator.GetList(50); }
public IList <UserModel> GetMultiple(int recordsNumber) { IList <UserModel> users = new List <UserModel>(); Hydrator <UserModel> hydrator = new Hydrator <UserModel>(); users = hydrator.GetList(recordsNumber); return(users); }
public void Generic_CanGetList() { var listCount = 50; var customers = hydrator.GetList(listCount) as IList; Assert.IsTrue(customers.Count == listCount, "Customer count is wrong."); //DumpCustomers(customers); }
public void CanGetList() { var listCount = 50; var hydrator = new Hydrator <SimpleCustomer>(); var customers = hydrator.GetList(listCount); Assert.IsTrue(customers.Count == listCount, "Customer count is wrong."); //DumpCustomers(customers); }
/// <summary> /// populate database for sample /// </summary> /// <param name="mongoDbSettings"></param> public async void populateDatabase(AutumnMongoDBSettings mongoDbSettings) { var client = new MongoClient(mongoDbSettings.ConnectionString); var database = client.GetDatabase(mongoDbSettings.Database); #region Customers var collection = database.GetCollection <CustomerV4>("customer"); var count = await collection.CountAsync(e => e.Id != null); if (count == 0) { var custormerHydrator = new Hydrator <CustomerV4>() .Ignoring(x => x.Id) .With(x => x.Address, new Hydrator <Address>() .WithAmericanCity(a => a.City) .WithAmericanPostalCode(a => a.PostalCode, 80) .WithAmericanAddress(a => a.Street) .WithAmericanState(a => a.State)) .With(x => x.BirthDate, new BirthDateGenerator()) .With(x => x.Active, new ActiveGenerator()) .WithEmailAddress(x => x.Email) .WithLastName(x => x.LastName) .WithFirstName(x => x.FirstName) .WithAlphaNumeric(x => x.Account, 10) .WithDouble(x => x.Credit, 0, 10000) .WithDouble(x => x.Credit, 0, 10000); var customers = custormerHydrator.GetList(500); await collection.InsertManyAsync(customers); } #endregion #region Articles var collection2 = database.GetCollection <ArticleInfoV2>("article"); count = await collection2.CountAsync(e => e.Id != null); if (count == 0) { var articleHydrator = new Hydrator <ArticleInfoV2>() .Ignoring(x => x.Id) .WithText(x => x.Content, 500) .WithAlphaNumeric(x => x.Title, 30) .WithInteger(x => x.Score, 0, 100) .WithDate(x => x.PublishDate, DateTime.Now.AddDays(-600), DateTime.Now.Date); var article = articleHydrator.GetList(100); await collection2.InsertManyAsync(article); } #endregion }
public void CanGetListOfComplexCustomer() { int[] values = {1, 2, 3}; var args = new object[] {values}; var hydrator = new Hydrator<ComplexCustomer>() .With(x => x.HomeAddress, new TypeGenerator<Address>()); var customerlist = hydrator.GetList(10); Assert.IsNotNull(customerlist); Assert.IsTrue(customerlist.Count == 10); Assert.IsNotNull(customerlist[1].HomeAddress, "CustomerAddress is null"); }
static void Main(string[] args) { //Console.WriteLine("Hello World!"); var hydrator = new Hydrator <SimpleCustomer>(); var customers = hydrator.GetList(5); foreach (var customer in customers) { Console.WriteLine(customer.FirstName); } Console.ReadLine(); }
public void CanGetListOfComplexCustomer() { int[] values = { 1, 2, 3 }; var args = new object[] { values }; var hydrator = new Hydrator <ComplexCustomer>() .With(x => x.HomeAddress, new TypeGenerator <Address>()); var customerlist = hydrator.GetList(10); Assert.IsNotNull(customerlist); Assert.IsTrue(customerlist.Count == 10); Assert.IsNotNull(customerlist[1].HomeAddress, "CustomerAddress is null"); }
public Repository() { Hydrator <CustomerDTO> hydrator = new Hydrator <CustomerDTO>(); Customers = hydrator.GetList(5); Random random = new Random(); Hydrator <OrdersDTO> ordersHydrator = new Hydrator <OrdersDTO>(); foreach (var customer in Customers) { customer.Orders = ordersHydrator.GetList(random.Next(1, 10)); } }
//Constructor public CustomerManager() { // Hydrator es un paquete nuget que permite la generacion de datos de ejemplo a partir de una clase dada Hydrator <CustomerDTO> hydratorData = new Hydrator <CustomerDTO>(); this.Customers = hydratorData.GetList(5); /* Variable de random define la cant. de ordenes para cada cliente */ Random numOrders = new Random(); Hydrator <OrdersDTO> ordenesHydrator = new Hydrator <OrdersDTO>(); foreach (CustomerDTO customer in this.Customers) { /*Agregamos numeros de ordenes aleatorias para cada cliente*/ customer.ordenes = ordenesHydrator.GetList(numOrders.Next(1, 10)); } }
//crear contructor //raiz Proyecto , BD, paquete Nuguet buscar: "hydrator" , foundation.ObjectHydrator:core (instalar) public Repository() { Hydrator <Models.CustomersDTO> hydrator = new Hydrator <Models.CustomersDTO>(); //creamos el conjunto de 5 resultados Customers = hydrator.GetList(5); //C16 crear unas ordenes aleatorias a cada cliente Random random = new Random(); Hydrator <Models.OrdersDTO> ordersHydrator = new Hydrator <Models.OrdersDTO>(); foreach (var customer in Customers) { customer.Orders = ordersHydrator.GetList(random.Next(1, 10)); } }
public Repository() { //Paso 5.2: Crear datos de ejemplo con el Nuget Fundation.ObjectHydrator para clientes Hydrator <CustomersDTO> hydrator = new Hydrator <CustomersDTO>(); Customers = hydrator.GetList(5); //Paso 7: Crear datos de ejemplo con el Nuget Fundation.ObjectHydrator para ordenes Random random = new Random(); Hydrator <OrdersDTO> ordersHydrator = new Hydrator <OrdersDTO>(); //Paso 8: Para Customers asignar ordenes aleatoria. foreach (var customer in Customers) { //Número de ordenes aleatoria de 1 al 10 customer.Orders = ordersHydrator.GetList(random.Next(1, 10)); } }
protected void Application_Start(object sender, EventArgs e) { //Create a list of companies and tuck them away for later use Hydrator<Company> hydrator2=new Hydrator<Company>(); IList<Company> comps = hydrator2.GetList(10); Application["companies"] = comps; //Create our customer database using one of the companies created above as the Company property of the customer. //Whoa. int listSize = 4; var args = new object[] { listSize }; //Hydrator<Customer> hydrator = new Hydrator<Customer>() // .FromList("Company", System.Linq.Enumerable.Cast<object>((IList<Company>)Application["companies"])) // .WithChildEntityList("Companies",typeof(Company),args); Hydrator<Customer> hydrator = new Hydrator<Customer>() .With(x => x.Company, new FromListGetSingleGenerator<Company>((IList<Company>)Application["companies"])) .With(x => x.Companies, new ListGenerator<Company>(listSize)); Application["customers"] = hydrator.GetList(50); }
public PeopleViewModel() { var hydrator = new Hydrator <Person>() .WithFirstName(n => n.Name); OriginalPeople = new List <Person>(hydrator.GetList(50)); People = new ObservableCollection <Person>(OriginalPeople); SelectedPerson = People.Skip(3).FirstOrDefault(); SearchCommand = new Command((searchValue) => { var filter = OriginalPeople .Where(s => s.Name .ToLower() .Contains(searchValue.ToString().ToLower())) .ToList(); People = new ObservableCollection <Person>(filter); }); ItemTappedCommand = new Command((item) => { var i = item; }); }
protected void Application_Start(object sender, EventArgs e) { //Create a list of companies and tuck them away for later use Hydrator <Company> hydrator2 = new Hydrator <Company>(); IList <Company> comps = hydrator2.GetList(10); Application["companies"] = comps; //Create our customer database using one of the companies created above as the Company property of the customer. //Whoa. int listSize = 4; var args = new object[] { listSize }; //Hydrator<Customer> hydrator = new Hydrator<Customer>() // .FromList("Company", System.Linq.Enumerable.Cast<object>((IList<Company>)Application["companies"])) // .WithChildEntityList("Companies",typeof(Company),args); Hydrator <Customer> hydrator = new Hydrator <Customer>() .With(x => x.Company, new FromListGetSingleGenerator <Company>((IList <Company>)Application["companies"])) .With(x => x.Companies, new ListGenerator <Company>(listSize)); Application["customers"] = hydrator.GetList(50); }
public List<Customer> GetAllCustomers() { Hydrator<Customer> _hydrator = new Hydrator<Customer>(); return _hydrator.GetList(50).ToList(); }
public FriendRepository() { Hydrator <Friend> _friendHydrator = new Hydrator <Friend>(); Friends = _friendHydrator.GetList(50); }
public void CanGetList() { var listCount = 50; var hydrator = new Hydrator<SimpleCustomer>(); var customers = hydrator.GetList(listCount); Assert.IsTrue(customers.Count == listCount, "Customer count is wrong."); //DumpCustomers(customers); }