Beispiel #1
0
 //
 // GET: /VirtualMta/Edit
 public ActionResult Edit(int id = WebInterfaceParameters.VIRTUALMTA_NEW_ID)
 {
     if (id == WebInterfaceParameters.VIRTUALMTA_NEW_ID)
     {
         return(View(new VirtualMTA()));
     }
     return(View(VirtualMtaDB.GetVirtualMta(id)));
 }
        public bool Save(SaveVirtualMtaViewModel viewModel)
        {
            VirtualMTA vMTA = null;

            if (viewModel.Id != WebInterfaceParameters.VIRTUALMTA_NEW_ID)
            {
                vMTA = VirtualMtaDB.GetVirtualMta(viewModel.Id);
            }
            else
            {
                vMTA = new VirtualMTA();
            }

            if (vMTA == null)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(viewModel.HostName))
            {
                return(false);
            }

            IPAddress ip = null;

            try
            {
                ip = IPAddress.Parse(viewModel.IpAddress);
            }
            catch (Exception)
            {
                return(false);
            }

            vMTA.Hostname       = viewModel.HostName;
            vMTA.IPAddress      = ip;
            vMTA.IsSmtpInbound  = viewModel.Inbound;
            vMTA.IsSmtpOutbound = viewModel.Outbound;
            OpenManta.WebLib.DAL.VirtualMtaDB.Save(vMTA);
            return(true);
        }