/// <summary>
 /// Fixed:
 /// </summary>
 public static System.Net.Mail.MailAddress From(Context context, int userId)
 {
     return(new System.Net.Mail.MailAddress(
                MailAddressUtilities.Get(
                    context: context,
                    userId: userId,
                    withFullName: true)));
 }
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string Editor(Context context, string reference, long id)
        {
            var ss = SiteSettingsUtilities.GetByReference(
                context: context,
                reference: reference,
                referenceId: id);

            if (context.ContractSettings.Mail == false)
            {
                return(Error.Types.Restricted.MessageJson(context: context));
            }
            if (MailAddressUtilities.Get(
                    context: context,
                    userId: context.UserId) == string.Empty)
            {
                return(new ResponseCollection()
                       .CloseDialog()
                       .Message(Messages.MailAddressHasNotSet(context: context))
                       .ToJson());
            }
            var invalid = OutgoingMailValidators.OnEditing(
                context: context,
                ss: ss);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson(context: context));
            }
            var outgoingMailModel = new OutgoingMailModel().Get(
                context: context,
                where : Rds.OutgoingMailsWhere().OutgoingMailId(
                    context.Forms.Long("OutgoingMails_OutgoingMailId")));
            var hb = new HtmlBuilder();

            return(new ResponseCollection()
                   .Html("#OutgoingMailDialog", hb
                         .Div(id: "MailEditorTabsContainer", action: () => hb
                              .Ul(id: "MailEditorTabs", action: () => hb
                                  .Li(action: () => hb
                                      .A(
                                          href: "#FieldSetMailEditor",
                                          text: Displays.Mail(context: context)))
                                  .Li(action: () => hb
                                      .A(
                                          href: "#FieldSetAddressBook",
                                          text: Displays.AddressBook(context: context))))
                              .FieldSet(id: "FieldSetMailEditor", action: () => hb
                                        .Form(
                                            attributes: new HtmlAttributes()
                                            .Id("OutgoingMailForm")
                                            .Action(Locations.Action(
                                                        context: context,
                                                        table: reference,
                                                        id: id,
                                                        controller: "OutgoingMails")),
                                            action: () => hb
                                            .Editor(
                                                context: context,
                                                ss: ss,
                                                outgoingMailModel: outgoingMailModel)))
                              .FieldSet(id: "FieldSetAddressBook", action: () => hb
                                        .Form(
                                            attributes: new HtmlAttributes()
                                            .Id("OutgoingMailDestinationForm")
                                            .Action(Locations.Action(
                                                        context: context,
                                                        table: reference,
                                                        id: id,
                                                        controller: "OutgoingMails")),
                                            action: () => hb
                                            .Destinations(context: context, ss: ss)))))
                   .Invoke("initOutgoingMailDialog")
                   .Focus("#OutgoingMails_Body")
                   .ToJson());
        }
 /// <summary>
 /// Fixed:
 /// </summary>
 public static System.Net.Mail.MailAddress From()
 {
     return(new System.Net.Mail.MailAddress(MailAddressUtilities.Get(
                                                Sessions.UserId(), withFullName: true)));
 }