Пример #1
0
        public async Task AddNewTernCharges(int userId, FormCollection collection)
        {
            var charges = new GrowingCharges
            {
                User            = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                GrowingType     = _growingTypeRepository.Get().FirstOrDefault(i => i.Name == "Tern"),
                ApplicationDate = DateTime.Parse(collection[1]),
                PlantName       = collection[2],
                Name            = collection[3],
                Document        = FileNameValidator(collection[4]),
                TotalCost       = Convert.ToDecimal(collection[5].Replace(".", ",")),
            };

            await _growingChargesRepository.AddAsync(charges);
        }
Пример #2
0
        private static GrowingCharges ConvertToChargesModel(NameValueCollection collection)
        {
            var      chargesmodel = new GrowingCharges();
            DateTime d1;

            if (DateTime.TryParse(collection[1], out d1))
            {
                chargesmodel.ApplicationDate = Convert.ToDateTime(collection[1]);
            }
            chargesmodel.PlantName = collection[2];
            chargesmodel.Name      = collection[3];
            chargesmodel.Document  = collection[4];
            decimal result;
            var     cost = collection[5].Replace(".", ",");

            if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result))
            {
                chargesmodel.TotalCost = Convert.ToDecimal(cost);
            }

            return(chargesmodel);
        }
Пример #3
0
        public async Task AddNewTernCharges(int userId, FormCollection collection)
        {
            var charges = new GrowingCharges
            {
                User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                GrowingType = _growingTypeRepository.Get().FirstOrDefault(i => i.Name == "Tern"),
                ApplicationDate = DateTime.Parse(collection[1]),
                PlantName = collection[2],
                Name = collection[3],
                Document = FileNameValidator(collection[4]),
                TotalCost = Convert.ToDecimal(collection[5].Replace(".", ",")),
            };

            await _growingChargesRepository.AddAsync(charges);
        }
        private static GrowingCharges ConvertToChargesModel(NameValueCollection collection)
        {
            var chargesmodel = new GrowingCharges();
            DateTime d1;
            if (DateTime.TryParse(collection[1], out d1)) chargesmodel.ApplicationDate = Convert.ToDateTime(collection[1]);
            chargesmodel.PlantName = collection[2];
            chargesmodel.Name = collection[3];
            chargesmodel.Document = collection[4];
            decimal result;
            var cost = collection[5].Replace(".", ",");
            if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result))
                chargesmodel.TotalCost = Convert.ToDecimal(cost);

            return chargesmodel;
        }