public ActionResult DeleteConfirmed(int id)
        {
            Gestation gestation = db.Gestations.Find(id);

            db.Gestations.Remove(gestation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //get gestation for partial view
        public ActionResult NewGestation(int id)
        {
            var model = new Gestation
            {
                IdCattle           = id,
                StartDateGestation = DateTime.Now.Date
            };

            return(PartialView("_NewGestation_Form", model));
        }
 public ActionResult Edit(Gestation gestation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gestation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Cattle", new { id = gestation.IdCattle }));
     }
     return(RedirectToAction("Details", "Cattle", new { id = gestation.IdCattle }));
 }
Beispiel #4
0
 public ActionResult Create(Gestation gestation)
 {
     if (ModelState.IsValid)
     {
         gestation.DateCalve = gestation.StartDateGestation.AddMonths(9);
         _db.Gestations.Add(gestation);
         _db.SaveChanges();
         return(RedirectToAction("Details", "Cattle", new { id = gestation.IdCattle }));
     }
     return(RedirectToAction("Details", "Cattle", new { id = gestation.IdCattle }));
 }
        public ActionResult Create(Gestation gestation)
        {
            if (ModelState.IsValid)
            {
                db.Gestations.Add(gestation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdCattle = new SelectList(db.Cattles, "IdCattle", "CodeCattle", gestation.IdCattle);
            return(View(gestation));
        }
Beispiel #6
0
 public bool AddGestation(Gestation gestation)
 {
     try
     {
         _db.Gestations.Add(gestation);
         _db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #7
0
        public bool EditGestation(Gestation gestation)
        {
            try
            {
                _db.Entry(gestation).State = EntityState.Modified;
                _db.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Beispiel #8
0
        public bool CreateGestation(Gestation gestation)
        {
            try
            {
                _db.Gestations.Add(gestation);
                _db.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        // GET: Gestations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gestation gestation = db.Gestations.Find(id);

            if (gestation == null)
            {
                return(HttpNotFound());
            }
            return(View(gestation));
        }
Beispiel #10
0
        public bool DeleteGestation(int id)
        {
            try
            {
                Gestation gestation = _db.Gestations.Find(id);
                _db.Gestations.Remove(gestation);
                _db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
        // GET: Gestations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gestation gestation = db.Gestations.Find(id);

            if (gestation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdCattle = new SelectList(db.Cattles, "IdCattle", "CodeCattle", gestation.IdCattle);
            return(View(gestation));
        }
Beispiel #12
0
 public bool EditGestation(Gestation gestation)
 {
     throw new NotImplementedException();
 }