コード例 #1
0
 public ActionResult Edit(AnimalWeightViewPar model)
 {
     if (ModelState.IsValid)
     {
         _weight.UpdateAnimalWeight(model);
         return RedirectToAction("GetAll");
     }
     return View(model);
 }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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);
                }
            }
        }