Ejemplo n.º 1
0
        private static GrowingFruitComings ConvertToFruitModel(NameValueCollection collection, string growingtype)
        {
            var fruitmodel = new GrowingFruitComings()
            {
                CultureType  = collection[3],
                Name         = collection[4],
                MassType     = collection[5],
                CurrencyType = collection[6]
            };
            DateTime d1; DateTime d2;

            if (DateTime.TryParse(collection[1], out d1))
            {
                fruitmodel.LandingDate = Convert.ToDateTime(collection[1]);
            }
            if (DateTime.TryParse(collection[2], out d2))
            {
                fruitmodel.FloweringDate = Convert.ToDateTime(collection[2]);
            }

            decimal result;
            var     cost = collection[7].Replace(".", ",");

            if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result))
            {
                fruitmodel.Cost = Convert.ToDecimal(cost);
            }
            var amount = collection[8].Replace(".", ",");

            if (!string.IsNullOrEmpty(amount) && decimal.TryParse(amount, out result))
            {
                fruitmodel.Amount = Convert.ToDecimal(amount);
            }

            fruitmodel.Document          = collection[9];
            fruitmodel.GrowingCultureses = _growingCulturesRepository.Get().Where(c => c.GrowingType.Name == growingtype);

            return(fruitmodel);
        }
Ejemplo n.º 2
0
        public GrowingFruitComings GetBergamotComingById(int id)
        {
            var picked = _growingFruitComingsRepository.Get().Where(i => i.Id == id).ToList()[0];

            return(new GrowingFruitComings
            {
                LandingDate = picked.LandingDate,
                FloweringDate = picked.FloweringDate,
                CultureType = picked.CultureType,
                Name = picked.Name,
                MassType = picked.MassType,
                CurrencyType = picked.CurrencyType,
                Cost = picked.Cost,
                Amount = picked.Amount,
                Document = picked.Document,
                GrowingCultureses = _growingCulturesRepository.Get().Where(c => c.GrowingType.Name == "Bergamot")
            });
        }