Esempio n. 1
0
        public JsonResult save(Vet_Appointment_Master vetApp)
        {
            bool     status = false;
            DateTime dateOrg;
            var      isValidDate = DateTime.TryParseExact(vetApp.VetDateString, "mm-dd-yyyy", null, System.Globalization.DateTimeStyles.None, out dateOrg);

            if (isValidDate)
            {
                vetApp.Appointment_Date = dateOrg;
            }

            var isValidModel = TryUpdateModel(vetApp);

            if (isValidModel)
            {
                using (Wollies_ShelterEntities dc = new Wollies_ShelterEntities())
                {
                    dc.Vet_Appointment_Master.Add(vetApp);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult Create([Bind(Include = "Vet_Appoint_Line_ID,Vet_ID,AppointmentDate,Description,Animal_ID,VetAppReasonsID")] Vet_Appointment_Master vet_Appointment_Master, DateTime?date)
        {
            if (ModelState.IsValid)
            {
                vet_Appointment_Master.AppointmentDate = date.Value;
                db.Vet_Appointment_Master.Add(vet_Appointment_Master);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            List <Animal> animals  = db.Animals.ToList();
            List <Animal> animals2 = new List <Animal>();

            foreach (Animal item in animals)
            {
                if (item.Animal_Status_ID == 2)
                {
                    animals2.Add(item);
                }
            }
            ViewBag.Animal_ID       = new SelectList(animals2, "Animal_Name", "Animal_Name", vet_Appointment_Master.Animal_ID);
            ViewBag.Vet_ID          = new SelectList(db.Veterinarians, "Vet_ID", "Vet_Name", vet_Appointment_Master.Vet_ID);
            ViewBag.VetAppReasonsID = new SelectList(db.VetAppReasons, "VetAppReasonsID", "Reason", vet_Appointment_Master.VetAppReasonsID);
            return(View(vet_Appointment_Master));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Vet_Appointment_Master vet_Appointment_Master = db.Vet_Appointment_Master.Find(id);

            db.Vet_Appointment_Master.Remove(vet_Appointment_Master);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Vet_Appoint_Line_ID,Vet_ID,AppointmentDate,Description,Animal_ID,VetAppReasonsID")] Vet_Appointment_Master vet_Appointment_Master)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vet_Appointment_Master).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Animal_ID       = new SelectList(db.Animals, "Animal_ID", "Animal_Name", vet_Appointment_Master.Animal_ID);
     ViewBag.Vet_ID          = new SelectList(db.Veterinarians, "Vet_ID", "Vet_Name", vet_Appointment_Master.Vet_ID);
     ViewBag.VetAppReasonsID = new SelectList(db.VetAppReasons, "VetAppReasonsID", "Reason", vet_Appointment_Master.VetAppReasonsID);
     return(View(vet_Appointment_Master));
 }
        // GET: VetAppointment/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Vet_Appointment_Master vet_Appointment_Master = db.Vet_Appointment_Master.Find(id);

            if (vet_Appointment_Master == null)
            {
                return(HttpNotFound());
            }
            return(View(vet_Appointment_Master));
        }
        // GET: VetAppointment/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Vet_Appointment_Master vet_Appointment_Master = db.Vet_Appointment_Master.Find(id);

            if (vet_Appointment_Master == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Animal_ID       = new SelectList(db.Animals, "Animal_ID", "Animal_Name", vet_Appointment_Master.Animal_ID);
            ViewBag.Vet_ID          = new SelectList(db.Veterinarians, "Vet_ID", "Vet_Name", vet_Appointment_Master.Vet_ID);
            ViewBag.VetAppReasonsID = new SelectList(db.VetAppReasons, "VetAppReasonsID", "Reason", vet_Appointment_Master.VetAppReasonsID);
            return(View(vet_Appointment_Master));
        }