public ActionResult DeleteConfirmed(int id)
        {
            CattleProduction cattleProduction = _db.CattleProductions.Find(id);

            _db.CattleProductions.Remove(cattleProduction);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "IdProduction,IdCattle,Dateprod,hourprod,quantity")] CattleProduction cattleProduction)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(cattleProduction).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdCattle = new SelectList(_db.Cattles, "IdCattle", "CodeCattle", cattleProduction.IdCattle);
     return(View(cattleProduction));
 }
예제 #3
0
 public bool EditCattleProductions(CattleProduction cattleProduction)
 {
     try
     {
         _db.Entry(cattleProduction).State = EntityState.Modified;
         _db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #4
0
 public bool AddCattleProduction(CattleProduction cattleProduction)
 {
     try
     {
         _db.CattleProductions.Add(cattleProduction);
         _db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        // GET: CattleProductions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CattleProduction cattleProduction = _db.CattleProductions.Find(id);

            if (cattleProduction == null)
            {
                return(HttpNotFound());
            }
            return(View(cattleProduction));
        }
        // GET: CattleProductions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CattleProduction cattleProduction = _dairyFarmService.GetCattleProductionById(id);

            if (cattleProduction == null)
            {
                return(HttpNotFound());
            }
            return(View(cattleProduction));
        }
        // GET: CattleProductions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CattleProduction cattleProduction = _db.CattleProductions.Find(id);

            if (cattleProduction == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdCattle = new SelectList(_db.Cattles, "IdCattle", "CodeCattle", cattleProduction.IdCattle);
            return(View(cattleProduction));
        }
        public ActionResult Edit(CattleProduction cattleProduction)
        {
            MessageInfo popup = new MessageInfo
            {
                Message = "Production bien ajouté",
                State   = 1
            };

            if (ModelState.IsValid)
            {
                if (_dairyFarmService.EditCattleProductions(cattleProduction) == false)
                {
                    popup.Message = "Erreur dans l'editon";
                    popup.State   = 0;
                }
                return(RedirectToAction("Index", new { message = popup.Message, state = popup.State }));
            }
            popup.Message = "Erreur dans l'editon";
            popup.State   = 0;
            return(RedirectToAction("Index", new { message = popup.Message, state = popup.State }));
        }