Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>

        public async Task <Brewery> Parse(String Row)
        {
            Loogers logError = new Loogers();

            try
            {
                Brewery Brewery = new Brewery();
                if (!string.IsNullOrEmpty(Row) && !string.IsNullOrWhiteSpace(Row))
                {
                    var Breweries = Row.Split(',');
                    if (Breweries.Length >= 12)
                    {
                        if (int.TryParse(Breweries[0].Trim('"'), out int Id))
                        {
                            Brewery.Id       = Id;
                            Brewery.name     = Breweries[1];
                            Brewery.address1 = Breweries[2];
                            Brewery.address2 = Breweries[3];
                            Brewery.city     = Breweries[4];
                            Brewery.state    = Breweries[5];
                            Brewery.code     = Breweries[6];
                            Brewery.country  = Breweries[7];
                            Brewery.phone    = Breweries[8];
                            Brewery.website  = Breweries[9];
                            Brewery.filepath = Breweries[10];
                            Brewery.descript = Breweries[11];
                            Brewery.last_mod = Breweries[12];
                            return(Brewery);
                        }
                        else
                        {
                            await logError.LogError($"El valor que no se puede conbertir es {Breweries[0]} ", "2");

                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                await logError.LogError(e.Message, "2");

                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>

        public async Task <Categories> Parse(String Row)
        {
            Loogers loogers = new Loogers();

            try
            {
                Categories categories = new Categories();
                if (!string.IsNullOrEmpty(Row) && !string.IsNullOrWhiteSpace(Row))
                {
                    var categor = Row.Split(',');
                    if (categor.Length == 2)
                    {
                        if (int.TryParse(categor[0].Trim('"'), out int Id))
                        {
                            categories.Id       = Id;
                            categories.cat_name = categor[1];
                            return(categories);
                        }
                        else
                        {
                            await loogers.LogError($"El valor que no se puede conbertir es {categor[0]} ", "2");

                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                await loogers.LogError(e.Message, "3");

                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>

        public async Task <Occasions> Parse(String Row)
        {
            Loogers logError = new Loogers();

            try
            {
                Occasions occasions = new Occasions();
                if (!string.IsNullOrEmpty(Row) && !string.IsNullOrWhiteSpace(Row))
                {
                    var occ = Row.Split(',');
                    if (occ.Length == 5)
                    {
                        occasions.BreweryDBStyleName = occ[0];
                        occasions.BreweryDBCategory  = occ[1];
                        occasions.CraftBeerCategory  = occ[2];
                        occasions.Scenario           = occ[3];
                        occasions.Description        = occ[4];
                        return(occasions);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                await logError.LogError(e.Message, "4");

                return(null);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>

        public async Task <Beer> Parse(String Row)
        {
            Loogers logError = new Loogers();

            try
            {
                Beer beer = new Beer();
                if (!string.IsNullOrEmpty(Row) && !string.IsNullOrWhiteSpace(Row))
                {
                    var Breweries = Row.Split(',');
                    if (Breweries.Length >= 10)
                    {
                        if (int.TryParse(Breweries[0].Trim('"'), out int Id))
                        {
                            if (int.TryParse((Breweries[1]).Trim('"'), out int Brewery_id))
                            {
                                if (int.TryParse((Breweries[3]).Trim('"'), out int Cat_id))
                                {
                                    if (int.TryParse((Breweries[4]).Trim('"'), out int Style_id))
                                    {
                                        beer.Id         = Id;
                                        beer.brewery_id = Brewery_id;
                                        beer.Beer_name  = Breweries[2];
                                        beer.cat_id     = Cat_id;
                                        beer.style_id   = Style_id;
                                        beer.abv        = Breweries[5];
                                        beer.ibu        = Breweries[6];
                                        beer.srm        = Breweries[7];
                                        beer.upc        = Breweries[8];
                                        beer.descript   = Breweries[9];
                                        return(beer);
                                    }
                                    else
                                    {
                                        await logError.LogError($"El valor que no se puede conbertir es {Breweries[4]} ", "1");

                                        return(null);
                                    }
                                }
                                else
                                {
                                    await logError.LogError($"El valor que no se puede conbertir es {Breweries[3]} ", "1");

                                    return(null);
                                }
                            }
                            else
                            {
                                await logError.LogError($"El valor que no se puede conbertir es {Breweries[1]} ", "1");

                                return(null);
                            }
                        }
                        else
                        {
                            await logError.LogError($"El valor que no se puede conbertir es {Breweries[0]} ", "1");

                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                await logError.LogError(e.Message, "1 Beer catalog");

                return(null);
            }
        }
        /// <summary>
        ///  este metodo es para transformar una linea de un arachivo a un objeto
        /// </summary>
        public async Task <Style> Parse(String Row)
        {
            Loogers logError = new Loogers();

            try
            {
                Style style = new Style();
                if (!string.IsNullOrEmpty(Row) && !string.IsNullOrWhiteSpace(Row))
                {
                    var styles = Row.Split(',');
                    if (styles.Length >= 14)
                    {
                        if (int.TryParse(styles[0].Trim('"'), out int Id))
                        {
                            if (int.TryParse(styles[1].Trim('"'), out int Cat_id))
                            {
                                style.Id          = Id;
                                style.cat_id      = Cat_id;
                                style.style_name  = styles[2];
                                style.Description = styles[3];
                                style.ABV_Low     = styles[4];
                                style.ABV_High    = styles[5];
                                style.IBU_low     = styles[6];
                                style.IBU_High    = styles[7];
                                style.SRM_Low     = styles[8];
                                style.SRM_High    = styles[9];
                                style.OG_Low      = styles[10];
                                style.OG_High     = styles[11];
                                style.FG_Low      = styles[12];
                                style.FG_High     = styles[13];
                                style.GlassType   = styles[14];
                                return(style);
                            }
                            else
                            {
                                await logError.LogError($"El valor que no se puede conbertir es {styles[1]} ", "5");

                                return(null);
                            }
                        }
                        else
                        {
                            await logError.LogError($"El valor que no se puede conbertir es {styles[0]} ", "5");

                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                await logError.LogError(e.Message, "5");

                return(null);
            }
        }