public ActionResult MaintainBreedType(Animal_Breed animal_breed, string button)
 {
     if (button == "Save")
     {
         try
         {
             Animal_Breed searchbreed = db.Animal_Breed.Find(animal_breed.Animal_Breed_ID);
             if (searchbreed == null)
             {
                 return(HttpNotFound());
             }
             else
             {
                 db.Entry(searchbreed).CurrentValues.SetValues(animal_breed);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             ViewBag.err = e.Message;
             return(RedirectToAction("MaintainDonationType", "Donations"));
         }
     }
     else if (button == "Cancel")
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Animal_Breed animal_Breed = db.Animal_Breed.Find(id);

            db.Animal_Breed.Remove(animal_Breed);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Id,ShortName,FullName")] Animal_Breed animal_Breed)
 {
     if (ModelState.IsValid)
     {
         db.Entry(animal_Breed).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(animal_Breed));
 }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,ShortName,FullName")] Animal_Breed animal_Breed)
        {
            if (ModelState.IsValid)
            {
                db.Animal_Breed.Add(animal_Breed);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(animal_Breed));
        }
예제 #5
0
        // GET: Animal_Breed/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Animal_Breed animal_Breed = db.Animal_Breed.Find(id);

            if (animal_Breed == null)
            {
                return(HttpNotFound());
            }
            return(View(animal_Breed));
        }
 public ActionResult AddBreedType(Animal_Breed animal_breed, string button)
 {
     ViewBag.errorMessage = "";
     if (button == "Save")
     {
         try
         {
             List <Animal_Breed> Animal_Breeds = new List <Animal_Breed>();
             Animal_Breeds = db.Animal_Breed.ToList();
             if (Animal_Breeds.Count != 0)
             {
                 int count = 0;
                 foreach (var item in Animal_Breeds)
                 {
                     if (item.Animal_Breed_Name == animal_breed.Animal_Breed_Name)
                     {
                         count++;
                         ViewBag.errorMessage = "There is a duplicate Donation Type Already";
                         return(View());
                     }
                 }
                 if (count == 0)
                 {
                     db.Animal_Breed.Add(animal_breed);
                     db.SaveChanges();
                 }
             }
             else
             {
                 db.Animal_Breed.Add(animal_breed);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             ViewBag.errorMessage = "There was an Error with network please try again: " + e.Message;
             return(View());
         }
     }
     else if (button == "Cancel")
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }