private static FishComings ConvertToFishesModel(NameValueCollection collection, string breedingtype) { var fishmodel = new FishComings { CultureType = collection[2], Name = collection[3], MassType = collection[4], CurrencyType = collection[5] }; DateTime d1; if (DateTime.TryParse(collection[1], out d1)) { fishmodel.ReceiptDate = Convert.ToDateTime(collection[1]); } decimal result1; decimal result2; var cost = collection[6].Replace(".", ","); if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result1)) { fishmodel.Cost = Convert.ToDecimal(cost); } var amount = collection[7].Replace(".", ","); if (!string.IsNullOrEmpty(amount) && decimal.TryParse(amount, out result2)) { fishmodel.Amount = Convert.ToDecimal(amount); } fishmodel.Document = collection[8]; fishmodel.BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == breedingtype); return(fishmodel); }
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); } }
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); } }
private static FishComings ConvertToFishesModel(NameValueCollection collection, string breedingtype) { var fishmodel = new FishComings { CultureType = collection[2], Name = collection[3], MassType = collection[4], CurrencyType = collection[5] }; DateTime d1; if (DateTime.TryParse(collection[1], out d1)) fishmodel.ReceiptDate = Convert.ToDateTime(collection[1]); decimal result1; decimal result2; var cost = collection[6].Replace(".", ","); if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result1)) fishmodel.Cost = Convert.ToDecimal(cost); var amount = collection[7].Replace(".", ","); if (!string.IsNullOrEmpty(amount) && decimal.TryParse(amount, out result2)) fishmodel.Amount = Convert.ToDecimal(amount); fishmodel.Document = collection[8]; fishmodel.BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == breedingtype); return fishmodel; }