예제 #1
0
        public ActionResult Edit(int id)
        {
            var service = new MedicalService();
            var detail  = service.GetMedicalById(id);
            var model   =
                new MedicalEdit
            {
                MedicalId    = detail.MedicalId,
                Name         = detail.Name,
                Location     = detail.Location,
                PhoneNumber  = detail.PhoneNumber,
                Website      = detail.Website,
                FinancialAid = detail.FinancialAid,
                Details      = detail.Details
            };

            return(View(model));
        }
예제 #2
0
        public bool UpdateMedical(MedicalEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Medicals
                    .Single(e => e.MedicalId == model.MedicalId);

                entity.Name         = model.Name;
                entity.Location     = model.Location;
                entity.PhoneNumber  = model.PhoneNumber;
                entity.Website      = model.Website;
                entity.FinancialAid = model.FinancialAid;
                entity.Details      = model.Details;

                return(ctx.SaveChanges() == 1);
            }
        }
예제 #3
0
        public ActionResult Edit(int id, MedicalEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MedicalId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new MedicalService();

            if (service.UpdateMedical(model))
            {
                TempData["SaveResult"] = "Medical Facility was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Medical Facility could not be updated.");
            return(View(model));
        }