public async Task AddNewTeplovyeFishComing(int userId, FormCollection collection)
        {
            var fish = new FishComings
            {
                User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "TeplovyeFish"),
                ReceiptDate = DateTime.Parse(collection[1]),
                CultureType = collection[2],
                Name = collection[3],
                MassType = collection[4],
                CurrencyType = collection[5],
                Cost = Convert.ToDecimal(collection[6].Replace(".", ",")),
                Amount = Convert.ToDecimal(collection[7].Replace(".", ",")),
                Document = FileNameValidator(collection[8])
            };

            _fishComingsRepository.Add(fish);
            var culturetype = collection[2];
            var name = collection[3];
            var firstOrDefault = _fishComingsRepository.Get().FirstOrDefault(c => c.CultureType == culturetype && c.Name == name);
            if (firstOrDefault != null)
            {
                var profit = new FishProfits
                {
                    Id = firstOrDefault.Id,
                    CultureType = collection[2],
                    Name = collection[3],
                    User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                    BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "TeplovyeFish")
                };
                await _fishProfitRepository.AddAsync(profit);
            }
        }
Exemplo n.º 2
0
        public async Task AddNewСoldwaterFishComing(int userId, FormCollection collection)
        {
            var fish = new FishComings
            {
                User         = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "СoldwaterFish"),
                ReceiptDate  = DateTime.Parse(collection[1]),
                CultureType  = collection[2],
                Name         = collection[3],
                MassType     = collection[4],
                CurrencyType = collection[5],
                Cost         = Convert.ToDecimal(collection[6].Replace(".", ",")),
                Amount       = Convert.ToDecimal(collection[7].Replace(".", ",")),
                Document     = FileNameValidator(collection[8])
            };

            _fishComingsRepository.Add(fish);
            var culturetype    = collection[2];
            var name           = collection[3];
            var firstOrDefault = _fishComingsRepository.Get().FirstOrDefault(c => c.CultureType == culturetype && c.Name == name);

            if (firstOrDefault != null)
            {
                var profit = new FishProfits
                {
                    Id           = firstOrDefault.Id,
                    CultureType  = collection[2],
                    Name         = collection[3],
                    User         = _usersRepository.Get().FirstOrDefault(i => i.Id == userId),
                    BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "СoldwaterFish")
                };
                await _fishProfitRepository.AddAsync(profit);
            }
        }