//getting all animals weighted
        public List<AnimalWeightViewPar> GetAllAnimalWeight()
        {
            using (var animalweight = new AnimalWeightRepository())
            {
                return animalweight.GetAll().Select(x => new AnimalWeightViewPar
                {
                    AnimalWeightId = x.AnimalWeightId,
                    AnimalCode = _animal.GetAll().ToList().Find(y => y.AnimalId == x.AnimalId).AniCode,
                    AverageWeight = x.AverageWeight,
                    DateWeighted = x.DateWeighted,
                    OriginalWeight = x.OriginalWeight

                }).ToList();
            }
        }
        //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);
            }
        }