Пример #1
0
        private static BeeComings ConvertToBeesModel(NameValueCollection collection, string breedingtype)
        {
            var beemodel = new BeeComings
            {
                CultureType  = collection[2],
                Name         = collection[3],
                CurrencyType = collection[4]
            };
            DateTime d1;

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

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

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

            return(beemodel);
        }
Пример #2
0
        public async Task AddNewBeeComing(int userId, FormCollection collection)
        {
            var bee = new BeeComings
            {
                User         = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "Bee"),
                ReceiptDate  = DateTime.Parse(collection[1]),
                CultureType  = collection[2],
                Name         = collection[3],
                CurrencyType = collection[4],
                Cost         = Convert.ToDecimal(collection[5].Replace(".", ",")),
                Amount       = Convert.ToInt32(collection[6]),
                Document     = FileNameValidator(collection[7])
            };

            await _beeComingsRepository.AddAsync(bee);
        }
        private static BeeComings ConvertToBeesModel(NameValueCollection collection, string breedingtype)
        {
            var beemodel = new BeeComings
            {
                CultureType = collection[2],
                Name = collection[3],
                CurrencyType = collection[4]
            };
            DateTime d1;
            if (DateTime.TryParse(collection[1], out d1)) beemodel.ReceiptDate = Convert.ToDateTime(collection[1]);
            decimal result1;
            var cost = collection[5].Replace(".", ",");
            if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result1))
                beemodel.Cost = Convert.ToDecimal(cost);
            var amount = collection[6];
            if (!string.IsNullOrEmpty(amount))
                beemodel.Amount = Convert.ToInt32(amount);
            beemodel.Document = collection[7];
            beemodel.BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == breedingtype);

            return beemodel;
        }
Пример #4
0
        public async Task AddNewBeeComing(int userId, FormCollection collection)
        {
            var bee = new BeeComings
            {
                User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "Bee"),
                ReceiptDate = DateTime.Parse(collection[1]),
                CultureType = collection[2],
                Name = collection[3],
                CurrencyType = collection[4],
                Cost = Convert.ToDecimal(collection[5].Replace(".", ",")),
                Amount = Convert.ToInt32(collection[6]),
                Document = FileNameValidator(collection[7])
            };

           await _beeComingsRepository.AddAsync(bee);
        }