コード例 #1
0
        public IActionResult Edit(EditVpnViewModel _vpn)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(PartialView("_Edit", _vpn));
                }
                _vpn.Password = EncryptionHelper.EncryptStringAES(_vpn.Password);
                var vpn = _mapper.Map <Vpn>(_vpn);

                _vpnRepo.Update(vpn);

                return(Json(Ok()));
            }
            catch (Exception ex)
            {
                return(Json(BadRequest("Error Occured while Updating VPN Details " + ex.Message)));
            }
        }
コード例 #2
0
        // GET: VpnController/Edit/5
        public IActionResult Edit(int id)
        {
            if (id < 0)
            {
                return(NotFound());
            }

            var _vpn = _vpnRepo.GetById(id);

            if (_vpn == null)
            {
                return(NotFound());
            }
            EditVpnViewModel vpn = _mapper.Map <EditVpnViewModel>(_vpn);
            var selectedClient   = _clientRepo.GetById(_vpn.ClientId);

            vpn.SelectedClient = _mapper.Map <CreateVpnClientViewModel>(selectedClient);

            vpn.Clients = _mapper.Map <IEnumerable <CreateVpnClientViewModel> >(_clientRepo.GetClients().Where(c => c.Id != selectedClient.Id));

            return(PartialView("_Edit", vpn));
        }