Esempio n. 1
0
        public ActionResult Form(int?id)
        {
            var model = new PatientFormModel();

            if (id != null)
            {
                var patient = db.patients.Find(id);
                if (patient == null)
                {
                    int?nullid = null;
                    return(RedirectToAction("Form", new { id = nullid }));
                }

                model.Load(id.Value);
                if (model.idFound)
                {
                    model.IsEdit = true;
                }
                else
                {
                    model.IsEdit = false;
                }
            }
            else
            {
                model.IsEdit = false;
            }
            return(View("Form", model));
        }
Esempio n. 2
0
        public ActionResult Form(PatientFormModel model)
        {
            if (ModelState.IsValid)
            {
                model.Save();
            }
            else
            {
                return(View(model));
            }
            int id = model.Id;

            return(RedirectToAction("form", new { id = id }));
        }