public ActionResult AddClaimInline(ClaimModel model) { if (ModelState.IsValid) { Context.Claims.Add(new Claim { Name = model.Name, Scope = model.Scope }); Context.SaveChanges(); } return PartialView("_AddClaimInline", model); }
public ActionResult EditClaim(ClaimModel model) { if (ModelState.IsValid) { Claim claim; if (!Context.Claims.TryGetById(model.Id, out claim)) throw new InvalidOperationException(string.Format("claim with id {0} was not found", model.Id)); claim.Name = model.Name; Context.SaveChanges(); } return JsonView(ModelState.IsValid, "_EditClaim", model); }
public ActionResult EditClaim(long claimId) { Claim claim; if (!Context.Claims.TryGetById(claimId, out claim)) throw new InvalidOperationException(string.Format("claim with id {0} was not found", claimId)); var model = new ClaimModel { Id = claim.Id, Name = claim.Name, Scope = claim.Scope }; return PartialView("_EditClaim", model); }