Exemplo n.º 1
0
        // GET: VpnController/Create
        public IActionResult Create()
        {
            var client = _mapper.Map <IEnumerable <CreateVpnClientViewModel> >(_clientRepo.GetClients());
            var server = new CreateVpnViewModel
            {
                Clients = client
            };

            return(PartialView("_Create", server));
        }
Exemplo n.º 2
0
        public IActionResult Create(CreateVpnViewModel _vpn)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(_vpn));
                }
                _vpn.Password = EncryptionHelper.EncryptStringAES(_vpn.Password);
                var vpn = _mapper.Map <Vpn>(_vpn);

                _vpnRepo.Create(vpn);
                return(Json(Ok()));
            }
            catch (Exception ex)
            {
                return(Json(BadRequest("Error Saving Vpn" + ex)));
            }
        }