public ActionResult Details()
 {
     using (var session = DocumentStore.GetStore().OpenSession("Configuration"))
     {
         var emailDefaultNotification = session.Load<EmailDefaultNotification>("EmailDefaultConfig");
         if (emailDefaultNotification == null)
             return RedirectToAction("Edit");
         var defaultEmailModel = new DefaultEmailModel {DefaultEmails = emailDefaultNotification.EmailAddresses.Join(", ")};
         return View("Details", defaultEmailModel);
     }
 }
 public ActionResult Edit()
 {
     using (var session = DocumentStore.GetStore().OpenSession("Configuration"))
     {
         var emailDefaultNotification = session.Load<EmailDefaultNotification>("EmailDefaultConfig");
         var defaultEmailModel = new DefaultEmailModel();
         if (emailDefaultNotification == null || emailDefaultNotification.EmailAddresses.Count == 0)
             return View("Edit", defaultEmailModel);
         var defaultEmails = emailDefaultNotification.EmailAddresses.Join(", ");
         defaultEmailModel.DefaultEmails = defaultEmails;
         return View("Edit", defaultEmailModel);
     }
 }
 public ActionResult Edit(DefaultEmailModel configuration)
 {
     var isValid = TryUpdateModel(configuration);
     if (!isValid)
         return View("Edit", configuration);
     using (var session = DocumentStore.GetStore().OpenSession("Configuration"))
     {
         var emailAddresses = configuration.DefaultEmails.Split(',');
         var cleanedEmailInList = emailAddresses.ToList().Select(e => e.Trim()).ToList();
         var emailDefaultNotification = session.Load<EmailDefaultNotification>("EmailDefaultConfig");
         if (emailDefaultNotification == null)
         {
             var defaultNotification = new EmailDefaultNotification {EmailAddresses = cleanedEmailInList};
             session.Store(defaultNotification, "EmailDefaultConfig");
         }
         else
         {
             emailDefaultNotification.EmailAddresses = cleanedEmailInList;
         }
         session.SaveChanges();
         return RedirectToAction("Details");
     }
 }