Esempio n. 1
0
        public ActionResult Create(PrivateKeyCreateViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var context = dataContextFactory.CreateByUser())
                    {
                        var privateKey = new Model.PrivateKey();
                        privateKey.SetKeyBytes();

                        privateKey.DisplayName = viewModel.DisplayName;
                        privateKey.Vendor = context.Vendors.Single(v => v.ObjectId == viewModel.VendorId);
                        context.PrivateKeys.Add(privateKey);

                        context.SaveChanges();
                    }
                    return RedirectToAction("Details", "Vendor", new { key = viewModel.VendorId });
                }
                else
                {
                    return View(viewModel);
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 2
0
        public ActionResult Create(PrivateKeyCreateViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var context = dataContextFactory.CreateByUser())
                    {
                        var privateKey = new Model.PrivateKey();
                        privateKey.SetKeyBytes();

                        privateKey.DisplayName = viewModel.DisplayName;
                        privateKey.Vendor      = context.Vendors.Single(v => v.ObjectId == viewModel.VendorId);
                        context.PrivateKeys.Add(privateKey);

                        context.SaveChanges();
                    }
                    return(RedirectToAction("Details", "Vendor", new { key = viewModel.VendorId }));
                }
                else
                {
                    return(View(viewModel));
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Convert back to PrivateKey instance
        /// </summary>
        /// <param name="original">Original PrivateKey. If Null a new instance is created.</param>
        /// <returns>PrivateKey containing viewmodel data </returns>
        public Model.PrivateKey ToEntity(Model.PrivateKey original)
        {
            if (original == null)
            {
                original = new Model.PrivateKey();
                original.SetKeyBytes();
            }
            Model.PrivateKey current = original;

            current.PrivateKeyId = this.PrivateKeyId;
            current.VendorId     = this.VendorId;
            current.DisplayName  = this.DisplayName;

            return(current);
        }
Esempio n. 4
0
        /// <summary>
        /// Convert back to PrivateKey instance
        /// </summary>
        /// <param name="original">Original PrivateKey. If Null a new instance is created.</param>
        /// <returns>PrivateKey containing viewmodel data </returns>
        public Model.PrivateKey ToEntity(Model.PrivateKey original)
        {
            if (original == null)
            {
                original = new Model.PrivateKey();
                original.SetKeyBytes();
            }
            Model.PrivateKey current = original;

            current.PrivateKeyId = this.PrivateKeyId;
            current.VendorId = this.VendorId;
            current.DisplayName = this.DisplayName;

            return current;
        }