public ActionResult Create([Bind(Include = "DocumentID,Title,PDF")] Document document)
        {
            if (ModelState.IsValid)
            {
                db.Documents.Add(document);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(document));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "ImageID,Link")] Image image)
        {
            if (ModelState.IsValid)
            {
                db.Images.Add(image);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(image));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "WeightID,Date,Weight1")] Weight weight)
        {
            if (ModelState.IsValid)
            {
                db.Weights.Add(weight);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(weight));
        }
        public ActionResult Create([Bind(Include = "VisitID,ClinicName,Cost,VisitDescription,VisitDate")] Visit visit)
        {
            if (ModelState.IsValid)
            {
                db.Visits.Add(visit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(visit));
        }
        public ActionResult Create([Bind(Include = "VaccinationID,Type,DateRecieved,DueDate")] Vaccination vaccination)
        {
            if (ModelState.IsValid)
            {
                db.Vaccinations.Add(vaccination);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vaccination));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "SurgeryID,date,description")] Surgery surgery)
        {
            if (ModelState.IsValid)
            {
                db.Surgeries.Add(surgery);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(surgery));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "PetID,Name,Birthdate,Type,Photo,IsFixed,SurgeryID,VaccinationID,WeightID,DocumentID,VisitID,ImageID")] Pet pet)
        {
            if (ModelState.IsValid)
            {
                db.Pets.Add(pet);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DocumentID    = new SelectList(db.Documents, "DocumentID", "Title", pet.DocumentID);
            ViewBag.ImageID       = new SelectList(db.Images, "ImageID", "ImageID", pet.ImageID);
            ViewBag.SurgeryID     = new SelectList(db.Surgeries, "SurgeryID", "description", pet.SurgeryID);
            ViewBag.VaccinationID = new SelectList(db.Vaccinations, "VaccinationID", "Type", pet.VaccinationID);
            ViewBag.VisitID       = new SelectList(db.Visits, "VisitID", "ClinicName", pet.VisitID);
            ViewBag.WeightID      = new SelectList(db.Weights, "WeightID", "WeightID", pet.WeightID);
            return(View(pet));
        }
Пример #8
0
 public List <dynamic> CreatePetType([FromBody] Pet_Type petType)
 {
     if (petType != null)
     {
         PetDBEntities db = new PetDBEntities();
         db.Configuration.ProxyCreationEnabled = false;
         db.Pet_Type.Add(petType);
         db.SaveChanges();
         return(getAllPetTypes());
     }
     else
     {
         return(null);
     }
 }
Пример #9
0
 public List <dynamic> CreatePets([FromBody] List <Pet> pets)
 {
     if (pets != null)
     {
         PetDBEntities db = new PetDBEntities();
         db.Configuration.ProxyCreationEnabled = false;
         db.Pets.AddRange(pets);
         db.SaveChanges();
         return(getAllPets());
     }
     else
     {
         return(null);
     }
 }
Пример #10
0
 public List <dynamic> UpdatePetType([FromBody] Pet_Type pet_Type)
 {
     if (pet_Type != null)
     {
         PetDBEntities db = new PetDBEntities();
         db.Configuration.ProxyCreationEnabled = false;
         Pet_Type objPrev = db.Pet_Type.Where(p => p.Pet_Type_ID == pet_Type.Pet_Type_ID).FirstOrDefault();
         objPrev.Pet_Type1 = pet_Type.Pet_Type1;
         db.SaveChanges();
         return(getAllPetTypes());
     }
     else
     {
         return(null);
     }
 }
Пример #11
0
 public List <dynamic> UpdatePet([FromBody] Pet pet)
 {
     if (pet != null)
     {
         PetDBEntities db = new PetDBEntities();
         db.Configuration.ProxyCreationEnabled = false;
         Pet objPrev = db.Pets.Where(p => p.Pet_ID == pet.Pet_ID).FirstOrDefault();
         objPrev.Pet_Type_ID   = pet.Pet_Type_ID;
         objPrev.Pet_Price     = pet.Pet_Price;
         objPrev.Pet_Quantitiy = pet.Pet_Quantitiy;
         db.SaveChanges();
         return(getAllPets());
     }
     else
     {
         return(null);
     }
 }
Пример #12
0
        public List <dynamic> DeletePet([FromBody] Pet pet)
        {
            PetDBEntities db = new PetDBEntities();

            db.Configuration.ProxyCreationEnabled = false;
            Pet objPrev = db.Pets.Where(p => p.Pet_ID == pet.Pet_ID).FirstOrDefault();

            if (objPrev != null)
            {
                db.Pets.Remove(objPrev);
                db.SaveChanges();
                return(getAllPets());
            }
            else
            {
                return(null);
            }
        }