Example #1
0
 public static void Main(string[] args)
 {
     NamesRepo.Init("./csvs/dataset_names.csv");
     ISO3166Repo.Init("./csvs/dataset_iso3166.csv");
     SurnamesRepo.Init("./csvs/dataset_surnames.csv");
     StatesRepo.Init("./csvs/dataset_us_states.csv");
     CitiesRepo.Init("./csvs/dataset_us_cities.csv");
     CreateHostBuilder(args).Build().Run();
 }
Example #2
0
        public void GetStatesTest()
        {
            StatesRepo myStates = new StatesRepo();
            var        states   = myStates.GetStates();

            Assert.AreEqual("MN", states[0].StateAbbreviation);
            Assert.AreEqual("Iowa", states[1].StateName);
            Assert.AreEqual(5.75, states[2].TaxRate);
            Assert.AreEqual("ND", states[3].StateAbbreviation);
            Assert.AreEqual("South Dakota", states[4].StateName);
        }
Example #3
0
 /// <summary>
 /// Obtener cantidad de registros de Sancion
 /// Autor: Jair Guerrero
 /// Fecha: 2020-12-05
 /// </summary>
 public int Count()
 {
     try
     {
         IRepository <States> repo = new StatesRepo(context);
         return(repo.Count());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Example #4
0
        /// <summary>
        /// Obtener Sancion por Id
        /// Autor: Jair Guerrero
        /// Fecha: 2020-12-05
        /// </summary>
        public StatesAM Get(long id)
        {
            try
            {
                IRepository <States> repo = new StatesRepo(context);
                var sancion = repo.Get(id);

                return(mapper.Map <StatesAM>(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Example #5
0
        /// <summary>
        /// Obtener cantidad de registros de Sancion segĂșn filtro
        /// Autor: Jair Guerrero
        /// Fecha: 2020-12-05
        /// </summary>
        public int Count(Expression <Func <StatesAM, bool> > predicate)
        {
            try
            {
                var where = mapper.MapExpression <Expression <Func <States, bool> > >(predicate);

                IRepository <States> repo = new StatesRepo(context);
                return(repo.Count(where));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Example #6
0
        /// <summary>
        /// Crear registro de Sancion
        /// Autor: Jair Guerrero
        /// Fecha: 2020-12-05
        /// </summary>
        public long Create(StatesAM entity)
        {
            try
            {
                var sancion = mapper.Map <States>(entity);

                IRepository <States> repo = new StatesRepo(context);
                return(repo.Create(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        /// <summary>
        /// Actualizar states
        /// Autor: Jair Guerrero
        /// Fecha: 2021-02-20
        /// </summary>
        public void Update(StatesAM entity)
        {
            try
            {
                var states = mapper.Map <States>(entity);

                IRepository <States> repo = new StatesRepo(context);
                repo.Update(states);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        /// <summary>
        /// Obtener lista de states
        /// Autor: Jair Guerrero
        /// Fecha: 2021-02-20
        /// </summary>
        public List <StatesAM> Get()
        {
            try
            {
                IRepository <States> repo = new StatesRepo(context);
                var states = repo.Get();

                return(mapper.Map <List <StatesAM> >(states));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Example #9
0
        /// <summary>
        /// Obtener primera Sancion segĂșn filtro
        /// Autor: Jair Guerrero
        /// Fecha: 2020-12-05
        /// </summary>
        public StatesAM GetFirst(Expression <Func <StatesAM, bool> > predicate)
        {
            try
            {
                var where = mapper.MapExpression <Expression <Func <States, bool> > >(predicate);

                IRepository <States> repo = new StatesRepo(context);
                var sancion = repo.GetFirst(where);

                return(mapper.Map <StatesAM>(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Example #10
0
 public IEnumerable <IState> GetAll() => StatesRepo.GetAll();