public ActionResult Edit(RaterEdit model)
        {
            var userId = Guid.Parse(User.Identity.GetUserId());

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateRaterService();

            if (service.EditRater(model))
            {
                TempData["SaveResult"] = "Your information was updated";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your information could not be updated");
            return(View(model));
        }
        public bool EditRater(RaterEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Raters.FirstOrDefault(r => r.OwnerID == model.UserID);

                entity.OwnerID = model.UserID;
                entity.Branch  = model.Branch;
                entity.Job     = model.Job;
                entity.Rank    = model.Rank;
                entity.Age     = model.Age;

                return(ctx.SaveChanges() == 1);
            }
        }
        //GET Edit
        public ActionResult Edit(int id)
        {
            var service = CreateRaterService();
            var detail  = service.GetRaterByID(id);
            var model   = new RaterEdit
            {
                UserID  = detail.UserID,
                RaterID = detail.RaterID,
                Branch  = detail.Branch,
                Job     = detail.Job,
                Rank    = detail.Rank,
                Age     = detail.Age,
            };

            return(View(model));
        }