コード例 #1
0
        public ActionResult Create([Bind(Include = "DistrictID,DistrictName")] District district)
        {
            if (ModelState.IsValid)
            {
                db.Districts.Add(district);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(district));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "DocID,Address,FirstName,LastName,Username,DOB,Email,RegionID,Password,isActive,TariffCode,isOnline")] Doctor doctor)
        {
            if (ModelState.IsValid)
            {
                db.Doctors.Add(doctor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RegionID = new SelectList(db.Regions, "RegionID", "RegionName", doctor.RegionID);
            return(View(doctor));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "AdminID,FirstName,LastName,userName,password,DistrictID")] Admin admin)
        {
            if (ModelState.IsValid)
            {
                db.Admins.Add(admin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", admin.DistrictID);
            return(View(admin));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "PatientID,FirstName,LastName,Email,Contact,Supervisor,PatientSince")] Patient patient)
        {
            if (ModelState.IsValid)
            {
                db.Patients.Add(patient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Supervisor = new SelectList(db.Doctors, "DocID", "Address", patient.Supervisor);
            return(View(patient));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "RegionID,RegionName,DistrictID")] Region region)
        {
            if (ModelState.IsValid)
            {
                db.Regions.Add(region);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", region.DistrictID);
            return(View(region));
        }
コード例 #6
0
 public void Save()
 {
     try
     {
         context.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                               eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                   ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
 }