예제 #1
0
        public ActionResult RegisterPatient(PatientModel model)
        {
            if (ModelState.IsValid)
            {
                using (ProductionDatabaseEntities entities = new ProductionDatabaseEntities())
                {
                    Patient patient = new Patient()
                    {
                        Address   = model.Address,
                        City      = model.City,
                        Id        = Guid.NewGuid(),
                        Name      = model.Name,
                        ZipCode   = model.ZipCode,
                        StateCode = model.StateCode
                    };
                    patient.Birthday = DateTime.Parse(model.Birthday);
                    patient.DoctorId = Guid.Parse(model.DoctorId);
                    entities.Patients.Add(patient);
                    entities.SaveChanges();
                }
                return(RedirectToAction("MyPatients", "Patient", new { id = model.DoctorId }));
            }

            // Return to orginal page because it operation failed.
            return(View("Index", model));
        }
        public JsonResult DeleteEvent(string id)
        {
            var  status = false;
            Guid guid   = Guid.Parse(id);

            var eventToRemove = db.Schedules.Where(a => a.EventId == guid).FirstOrDefault();

            if (eventToRemove != null)
            {
                db.Schedules.Remove(eventToRemove);
                db.SaveChanges();
                status = true;
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }