public ActionResult DeleteConfirmed(int id)
        {
            CattleType cattleType = db.CattleTypes.Find(id);

            db.CattleTypes.Remove(cattleType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public bool AddCattleType(CattleType cattleType)
 {
     if (cattleTypeDAL.GetAll().Any(x => x.Name.ToLower() == cattleType.Name.ToLower() && x.RanchID == cattleType.RanchID))
     {
         return(false);
     }
     return(cattleTypeDAL.Add(cattleType) > 0);
 }
        internal static List<CattleDto> CreateCattle(int count, CattleType cattleType)
        {
            var animals = new List<CattleDto>();
            for (var i = 0; i < count; i++)
            {
                animals.Add(new CattleDto { Type = cattleType });
            }

            return animals;
        }
 public ActionResult Edit([Bind(Include = "IdCattleType,Label,Sex")] CattleType cattleType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cattleType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cattleType));
 }
        public ActionResult AddCattleType(CattleType cattleType)
        {
            if (!new BLL.CattleTypeController().AddCattleType(cattleType))
            {
                ViewBag.Message = "Aynı isimde tür mevcut !!";
                return(View("AddCattleType", new BLL.CategoryController().GetCategories()));
            }

            return(RedirectToAction("Index", new { CategoryID = cattleType.CategoryID }));
        }
        public ActionResult Create([Bind(Include = "IdCattleType,Label,Sex")] CattleType cattleType)
        {
            if (ModelState.IsValid)
            {
                db.CattleTypes.Add(cattleType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cattleType));
        }
        public ActionResult DeleteCattleType(int CattleTypeID)
        {
            BLL.CattleTypeController cTContoller = new BLL.CattleTypeController();
            CattleType cattleType = cTContoller.GetAll((int)Session["Id"]).FirstOrDefault(x => x.ID == CattleTypeID);

            if (!cTContoller.DeleteCattleType(cattleType) || cattleType == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index", new { cattleType.CategoryID }));
        }
Exemple #8
0
 public bool AddCattleType(CattleType cattleType)
 {
     try
     {
         _db.CattleTypes.Add(cattleType);
         _db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #9
0
 public bool EditCattleType(CattleType cattleType)
 {
     try
     {
         _db.Entry(cattleType).State = EntityState.Modified;
         _db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #10
0
        // GET: CattleTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CattleType cattleType = _dairyFarmService.GetCattleTypeById(id);

            if (cattleType == null)
            {
                return(HttpNotFound());
            }
            return(View(cattleType));
        }
        // GET: CattleTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CattleType cattleType = db.CattleTypes.Find(id);

            if (cattleType == null)
            {
                return(HttpNotFound());
            }
            return(View(cattleType));
        }
Exemple #12
0
 public ActionResult Create(CattleType cattleType)
 {
     if (ModelState.IsValid)
     {
         var popup = new MessageInfo
         {
             State   = 1,
             Message = "Type bien ajouté"
         };
         if (_dairyFarmService.AddCattleType(cattleType) == false)
         {
             return(RedirectToAction("Index", "CattleTypes", new { message = "Erreur dans l'ajout", state = 0 }));
         }
         return(RedirectToAction("Index", "CattleTypes", new { message = popup.Message, state = popup.State }));
     }
     return(RedirectToAction("Index", "CattleTypes", new { message = "Erreur dans l'ajout", state = 0 }));
 }
Exemple #13
0
        // GET: CattleTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CattleType cattleType = _dairyFarmService.GetCattleTypeById(id);

            if (cattleType == null)
            {
                return(HttpNotFound());
            }
            var listSelect = new List <object>
            {
                new { Text = "Mâle", Value = "M" },
                new { Text = "Femelle", Value = "F" }
            };

            ViewBag.List = new SelectList(listSelect, "Text", "Value");
            return(View(cattleType));
        }
Exemple #14
0
 public int Delete(CattleType cattleType)
 {
     db.Entry(cattleType).State = EntityState.Deleted;
     return(db.SaveChanges());
 }
Exemple #15
0
 public int Update(CattleType cattleType)
 {
     db.Entry(cattleType).State = EntityState.Modified;
     return(db.SaveChanges());
 }
Exemple #16
0
 public int Add(CattleType cattleType)
 {
     db.Entry(cattleType).State = EntityState.Added;
     return(db.SaveChanges());
 }
 public bool DeleteCattleType(CattleType cattleType)
 {
     return(cattleTypeDAL.Delete(cattleType) > 0);
 }
 internal static List<CattleDto> CreateCattle(this List<CattleDto> animals, int count, CattleType cattleType)
 {
     animals.AddRange(FarmPactRepository.CreateCattle(count, cattleType));
     return animals;
 }