Пример #1
0
        public void AddNewCattlemixedYoung(int userId, FormCollection collection)
        {
            var youngcamel = new YoungBreeding
            {
                User         = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "Cattlemixed"),
                ReceiptDate  = DateTime.Parse(collection[1]),
                CultureType  = collection[2],
                Name         = collection[3],
                MassType     = collection[4],
                Mass         = Convert.ToDecimal(collection[5].Replace(".", ",")),
                CurrencyType = collection[6],
                Cost         = Convert.ToDecimal(collection[7].Replace(".", ",")),
                Amount       = Convert.ToInt32(collection[8]),
                Document     = FileNameValidator(collection[9])
            };

            _youngBreedingRepository.Add(youngcamel);
        }
        public void AddNewSheepYoung(int userId, FormCollection collection)
        {
            var youngcamel = new YoungBreeding
            {
                User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "Sheep"),
                ReceiptDate = DateTime.Parse(collection[1]),
                CultureType = collection[2],
                Name = collection[3],
                MassType = collection[4],
                Mass = Convert.ToDecimal(collection[5].Replace(".", ",")),
                CurrencyType = collection[6],
                Cost = Convert.ToDecimal(collection[7].Replace(".", ",")),
                Amount = Convert.ToInt32(collection[8]),
                Document = FileNameValidator(collection[9])
            };

            _youngBreedingRepository.Add(youngcamel);
        }
Пример #3
0
        private static YoungBreeding ConvertToYoungModel(NameValueCollection collection, string breedingtype)
        {
            var youngmodel = new YoungBreeding
            {
                CultureType  = collection[2],
                Name         = collection[3],
                MassType     = collection[4],
                CurrencyType = collection[6]
            };
            DateTime d1;

            if (DateTime.TryParse(collection[1], out d1))
            {
                youngmodel.ReceiptDate = Convert.ToDateTime(collection[1]);
            }
            decimal result1;
            var     mass = collection[5].Replace(".", ",");

            if (!string.IsNullOrEmpty(mass) && decimal.TryParse(mass, out result1))
            {
                youngmodel.Mass = Convert.ToDecimal(mass);
            }
            decimal result2;
            var     cost = collection[7].Replace(".", ",");

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

            if (!string.IsNullOrEmpty(amount))
            {
                youngmodel.Amount = Convert.ToInt32(amount);
            }
            youngmodel.Document           = collection[9];
            youngmodel.BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == breedingtype);

            return(youngmodel);
        }
        private static YoungBreeding ConvertToYoungModel(NameValueCollection collection, string breedingtype)
        {
            var youngmodel = new YoungBreeding
            {
                CultureType = collection[2],
                Name = collection[3],
                MassType = collection[4],
                CurrencyType = collection[6]
            };
            DateTime d1;
            if (DateTime.TryParse(collection[1], out d1)) youngmodel.ReceiptDate = Convert.ToDateTime(collection[1]);
            decimal result1;
            var mass = collection[5].Replace(".", ",");
            if (!string.IsNullOrEmpty(mass) && decimal.TryParse(mass, out result1))
                youngmodel.Mass = Convert.ToDecimal(mass);
            decimal result2;
            var cost = collection[7].Replace(".", ",");
            if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result2))
                youngmodel.Cost = Convert.ToDecimal(cost);
            var amount = collection[8];
            if (!string.IsNullOrEmpty(amount))
                youngmodel.Amount = Convert.ToInt32(amount);
            youngmodel.Document = collection[9];
            youngmodel.BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == breedingtype);

            return youngmodel;
        }