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); }
public BeeComings GetBeeComingById(int id) { var picked = _beeComingsRepository.Get().Where(i => i.Id == id).ToList()[0]; return(new BeeComings { ReceiptDate = picked.ReceiptDate, CultureType = picked.CultureType, Name = picked.Name, CurrencyType = picked.CurrencyType, Cost = picked.Cost, Amount = picked.Amount, Document = picked.Document, BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == "Bee") }); }