//weigh animal public void AddAnimalWeight(AnimalWeightView model) { using (var animalweight = new AnimalWeightRepository()) { var weight = new AnimalWeight { AnimalWeightId = model.AnimalWeightId, DateWeighted = DateTime.Now, OriginalWeight = model.OriginalWeight, AverageWeight = model.AverageWeight, AnimalId = model.AnimalId }; List<AnimalWeight> listAni = animalweight.GetAll().ToList().FindAll(x => x.AnimalId == model.AnimalId).ToList(); weight.AverageWeight += ((model.OriginalWeight+listAni.Sum(x => x.OriginalWeight)) / (listAni.Count+1)); animalweight.Insert(weight); } }
public void Update(AnimalWeight model) { _animalweightRepository.Update(model); }
public void Insert(AnimalWeight model) { _animalweightRepository.Insert(model); }
public void Delete(AnimalWeight model) { _animalweightRepository.Delete(model); }