Esempio n. 1
0
        public ActionResult Edit(VendorCredentialModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                var resultModel = VendorCredentialModel.ForEdit(dataContextFactory, inputModel.VendorCredentialId.Value);
                resultModel.CredentialName  = inputModel.CredentialName;
                resultModel.CredentialValue = inputModel.CredentialValue;
                return(View("CreateEdit", resultModel));
            }

            using (var dataContext = dataContextFactory.Create())
            {
                var vendorCredential =
                    dataContext.VendorCredentials.Where(x => x.VendorCredentialId == inputModel.VendorCredentialId.Value).Single();

                vendorCredential.CredentialName  = inputModel.CredentialName;
                vendorCredential.CredentialValue =
                    SymmetricEncryption.EncryptForDatabase(Encoding.UTF8.GetBytes(inputModel.CredentialValue));

                dataContext.SaveChanges();
            }

            Flash.Success("VendorCredential was successfully modified.");
            return(RedirectToAction("Details", "Vendor", new { key = inputModel.VendorId }));
        }
Esempio n. 2
0
        public ActionResult Remove(Guid VendorId, Guid VendorCredentialId)
        {
            if (!ModelState.IsValid)
            {
                var resultModel = VendorCredentialModel.ForEdit(dataContextFactory, VendorCredentialId);
                return(View("Remove", resultModel));
            }

            using (var dataContext = dataContextFactory.Create())
            {
                dataContext.VendorCredentials.Remove(s => s.VendorCredentialId == VendorCredentialId);
                dataContext.SaveChanges();
            }

            Flash.Success("VendorCredential was successfully deleted.");
            return(RedirectToAction("Details", "Vendor", new { key = VendorId }));
        }
Esempio n. 3
0
        public ActionResult Remove(Guid key)
        {
            var model = VendorCredentialModel.ForEdit(dataContextFactory, key);

            return(View("Remove", model));
        }