public async Task AddNewQuailCharges(int userId, FormCollection collection) { var charges = new BreedingCharges { User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId), BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "Quail"), ApplicationDate = DateTime.Parse(collection[1]), AnimalName = collection[2], Name = collection[3], Document = FileNameValidator(collection[4]), TotalCost = Convert.ToDecimal(collection[5].Replace(".", ",")) }; await _breedingChargesRepository.AddAsync(charges); }
private static BreedingCharges ConvertToChargesModel(NameValueCollection collection) { var chargesmodel = new BreedingCharges(); DateTime d1; if (DateTime.TryParse(collection[1], out d1)) { chargesmodel.ApplicationDate = Convert.ToDateTime(collection[1]); } chargesmodel.AnimalName = collection[2]; chargesmodel.Name = collection[3]; chargesmodel.Document = collection[4]; decimal result; var cost = collection[5].Replace(".", ","); if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result)) { chargesmodel.TotalCost = Convert.ToDecimal(cost); } return(chargesmodel); }
public async Task AddNewPinscherdogCharges(int userId, FormCollection collection) { var charges = new BreedingCharges { User = _usersRepository.Get().FirstOrDefault(i => i.Id == userId), BreedingType = _breedingTypeRepository.Get().FirstOrDefault(i => i.Name == "Pinscherdog"), ApplicationDate = DateTime.Parse(collection[1]), AnimalName = collection[2], Name = collection[3], Document = FileNameValidator(collection[4]), TotalCost = Convert.ToDecimal(collection[5].Replace(".", ",")), }; await _breedingChargesRepository.AddAsync(charges); }
private static BreedingCharges ConvertToChargesModel(NameValueCollection collection) { var chargesmodel = new BreedingCharges(); DateTime d1; if (DateTime.TryParse(collection[1], out d1)) chargesmodel.ApplicationDate = Convert.ToDateTime(collection[1]); chargesmodel.AnimalName = collection[2]; chargesmodel.Name = collection[3]; chargesmodel.Document = collection[4]; decimal result; var cost = collection[5].Replace(".", ","); if (!string.IsNullOrEmpty(cost) && decimal.TryParse(cost, out result)) chargesmodel.TotalCost = Convert.ToDecimal(cost); return chargesmodel; }