コード例 #1
0
 public PartialViewResult ContactSettings(string workspace)
 {
   ContactSettingsModel m;
   if (TempData.ContainsKey("contactSettingsModel"))
     m = (ContactSettingsModel)TempData["contactSettingsModel"];
   else
   {
     m = new ContactSettingsModel();
     var w = new ContactAppWorkspace(AppService.GetWorkspace(workspace));
     if (w.Contact != null)
     {
       //TODO: use automapper?
       m.Mode = w.Contact.Mode.ToString();
       m.To = w.Contact.To;
       m.Host = w.Contact.Host;
       m.Port = w.Contact.Port;
       m.UserName = w.Contact.UserName;
       m.Password = w.Contact.Password;
     }
   }
   return PartialView("ContactSettingsWidget", m);
 }
コード例 #2
0
 public ActionResult UpdateSettings(string workspace, ContactSettingsModel m)
 {
   try
   {
     var w = new ContactAppWorkspace(AppService.GetWorkspace(workspace));
     if (w.Contact == null)
     {
       w.Contact = new Contact();
     }
     // TODO: validation, also use Automapper?
     w.Contact.Mode = (ContactMode)Enum.Parse(typeof(ContactMode), m.Mode);
     w.Contact.To = m.To;
     w.Contact.Host = m.Host;
     w.Contact.Port = m.Port;
     w.Contact.UserName = m.UserName;
     w.Contact.Password = m.Password;
     AtomPubService.UpdateService(AppService);
     TempData["saved"] = true;
   }
   catch (Exception ex)
   {
     LogService.Error(ex);
     m.Errors.Add(ex.Message);
   }
   TempData["contactSettingsModel"] = m;
   return RedirectToAction("Settings", "Admin", new { workspace = workspace });
 }