public void DeleteAnimalWeight(int id) { using (var animalweight = new AnimalWeightRepository()) { AnimalWeight weight = animalweight.GetById(id); if (weight != null) { animalweight.Delete(weight); } } }
public AnimalWeightViewPar GetByIdAnimalWeight(int id) { using (var animalweight = new AnimalWeightRepository()) { AnimalWeight weight = animalweight.GetById(id); var weightView = new AnimalWeightViewPar(); if (weight != null) { weightView.AnimalWeightId = weight.AnimalWeightId; weightView.AnimalCode = _animal.GetAll().ToList().Find(x => x.AnimalId == weight.AnimalId).AniCode; weightView.AverageWeight = weight.AverageWeight; weightView.DateWeighted = weight.DateWeighted; weightView.OriginalWeight = weight.OriginalWeight; } return weightView; } }
public void UpdateAnimalWeight(AnimalWeightViewPar model) { using (var animalweight = new AnimalWeightRepository()) { AnimalWeight weight = animalweight.GetById(model.AnimalWeightId); if (weight != null) { weight.AnimalWeightId = model.AnimalWeightId; //weight.AnimalId =_animal.GetAll().ToList().Find(y => y.AnimalId == weight.AnimalId).AniCode.ToString(); weight.AverageWeight = model.AverageWeight; weight.DateWeighted = model.DateWeighted; weight.OriginalWeight = model.OriginalWeight; animalweight.Update(weight); } } }