public ActionResult MainatainAnimalType(Animal_Type animal_Type, string button)
 {
     if (button == "Save")
     {
         try
         {
             Animal_Type searchaniaml = db.Animal_Type.Find(animal_Type.Animal_Type_ID);
             if (searchaniaml == null)
             {
                 return(HttpNotFound());
             }
             else
             {
                 db.Entry(searchaniaml).CurrentValues.SetValues(animal_Type);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             TempData["EditMessage"] = e.Message;
             return(RedirectToAction("MaintainDonationType", "Donations"));
         }
     }
     else if (button == "Cancel")
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
        public ActionResult MainatainAnimalType(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Animal_Type animal_type = db.Animal_Type.Find(id);

            if (animal_type == null)
            {
                return(HttpNotFound());
            }
            return(View(animal_type));
        }
        public ActionResult AddAnimalType(Animal_Type animal_type, string button)
        {
            ViewBag.errorMessage = "";
            //Donation_Type asd = new Donation_Type();
            if (button == "Save")
            {
                try
                {
                    List <Animal_Type> Animal_Type = new List <Animal_Type>();
                    Animal_Type = db.Animal_Type.ToList();
                    if (Animal_Type.Count != 0)
                    {
                        int count = 0;
                        foreach (var item in Animal_Type)
                        {
                            if (item.Animal_Type_Name == animal_type.Animal_Type_Name)
                            {
                                count++;
                                ViewBag.errorMessage = "There is a duplicate Donation Type Already";
                                return(View());
                            }
                        }
                        if (count == 0)
                        {
                            db.Animal_Type.Add(animal_type);
                            db.SaveChanges();
                            TempData["SuccessMessage"] = "Successfully Stored";
                        }
                    }
                    else
                    {
                        db.Animal_Type.Add(animal_type);
                        db.SaveChanges();

                        TempData["SuccessMessage"] = "Successfully Stored";
                    }
                }
                catch (Exception e)
                {
                    TempData["EditMessage"] = "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"));
        }