Ejemplo n.º 1
0
        public ActionResult Edit(PrivateKeyEditViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var context = dataContextFactory.CreateByUser())
                    {
                        var privateKey = context.PrivateKeys.SingleOrDefault(k => k.PrivateKeyId == viewModel.PrivateKey.PrivateKeyId);

                        if (privateKey == null)
                            return new HttpNotFoundResult();

                        privateKey.DisplayName = viewModel.PrivateKey.DisplayName;

                        context.SaveChanges();
                        Flash.Success("Private key was updated.");
                    }
                    return RedirectToAction("Details", "Vendor", new { key = viewModel.PrivateKey.VendorId });
                }
                else
                {
                    return View(viewModel);
                }
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Edit a single privateKey
        /// </summary>
        /// <param name="key">GUID of privateKey to edit</param>
        /// <returns>Edit privateKey view</returns>
        public ActionResult Edit(Guid key)
        {
            using (var context = dataContextFactory.CreateByUser())
            {
                var privateKey = context.PrivateKeys.SingleOrDefault(k => k.PrivateKeyId == key);

                if (privateKey == null)
                    return new HttpNotFoundResult();

                PrivateKeyEditViewModel viewModel = new PrivateKeyEditViewModel(privateKey);

                return View(viewModel);
            }
        }