private static BeeHoney ConvertToHoneyModel(NameValueCollection collection, string breedingtype) { var honeymodel = new BeeHoney { AnimalName = collection[2], HoneyType = collection[3], MassType = collection[4] }; DateTime d1; if (DateTime.TryParse(collection[1], out d1)) { honeymodel.Date = Convert.ToDateTime(collection[1]); } decimal result1; decimal result2; var amount = collection[5].Replace(".", ","); if (!string.IsNullOrEmpty(amount) && decimal.TryParse(amount, out result1)) { honeymodel.Amount = Convert.ToDecimal(amount); } var cost = collection[6].Replace(".", ","); if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result2)) { honeymodel.Cost = Convert.ToDecimal(cost); } honeymodel.Document = collection[7]; honeymodel.BreedingCultureses = _breedingCulturesRepository.Get().Where(c => c.BreedingType.Name == breedingtype); honeymodel.HoneyTypeses = _honeyTypeRepository.Get().ToList(); return(honeymodel); }
public BeeHoney GetBeeHoneyById(int id) { var picked = _beeHoneyRepository.Get().FirstOrDefault(i => i.Id == id); if (picked != null) { return new BeeHoney { Date = picked.Date, HoneyType = picked.HoneyType, MassType = picked.MassType, Amount = picked.Amount, Cost = picked.Cost, Document = picked.Document, AnimalName = picked.AnimalName, HoneyTypeses = _honeyTypeRepository.Get().ToList() } } ; return(null); }