Ejemplo n.º 1
0
 public bool UpdateInvestigator(InvestigatorEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Investigators
             .Single(e => e.InvestigatorID == model.InvestigatorID);
         entity.Name        = model.Name;
         entity.Email       = model.Email;
         entity.Address     = model.Email;
         entity.PhoneNumber = model.PhoneNumber;
         return(ctx.SaveChanges() == 1);
     }
 }
Ejemplo n.º 2
0
        public ActionResult InvestigatorEdit(int id)
        {
            var svc    = new InvestigatorService();
            var detail = svc.GetInvestigatorByID(id);
            var model  =
                new InvestigatorEdit
            {
                InvestigatorID = detail.InvestigatorID,
                Name           = detail.Name,
                Email          = detail.Email,
                Address        = detail.Address,
                PhoneNumber    = detail.PhoneNumber,
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult InvestigatorEdit(int id, InvestigatorEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var svc = new InvestigatorService();

            if (svc.UpdateInvestigator(model))
            {
                TempData["SaveResult"] = "The Investigator was updated.";
                return(RedirectToAction("Index"));
            }

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