public ActionResult Remove(PrivateKeyRemoveModel model) { using (var context = dataContextFactory.CreateByUser()) { context.PrivateKeys.Remove(x => x.PrivateKeyId == model.PrivateKeyId); context.SaveChanges(); return Redirect(model.RedirectUrl ?? Url.Action("Index", "Home")); } }
/// <summary> /// Remove a single privateKey /// </summary> /// <param name="key">GUID of privateKey to remove</param> /// <returns></returns> public ActionResult Remove(Guid key) { using (var context = dataContextFactory.CreateByUser()) { var privateKey = context.PrivateKeys.Where(k => k.PrivateKeyId == key) .Include(k => k.Vendor) .SingleOrDefault(); if (privateKey == null) return new HttpNotFoundResult(); var model = new PrivateKeyRemoveModel() { PrivateKeyId = privateKey.PrivateKeyId, PrivateKeyName = privateKey.DisplayName, VendorName = privateKey.Vendor.Name }; model.UseLocalReferrerAsRedirectUrl(Request); return View(model); } }