Esempio n. 1
0
        //public static string DisplayVotingMethodFor(Election currentElection, Person person)
        //{
        //  //p.VotingMethod.DefaultTo(VotingMethodEnum.InPerson) == VotingMethodEnum.InPerson ? null : p.EnvNum

        //  var item = BaseItems.SingleOrDefault(i => i.Value == person.VotingMethod);
        //  if (item == null)
        //  {
        //    // unknown!
        //    return person.VotingMethod;
        //  }
        //  if (item == InPerson)
        //  {
        //    // don't show anything for In Person voters
        //    return "";
        //  }

        //  var envNum = person.EnvNum.AsInt(0);
        //  var envNumText = envNum == 0 ? "?" : envNum.ToString();

        //  if (currentElection.MaskVotingMethod.AsBoolean())
        //  {
        //    return "Envelope " + envNumText;
        //  }

        //  return string.Format("{1} <span>{0}</span> {2}", item.DisplayText, envNumText, " ".PadRight(envNumText.Length).Replace(" ", "&nbsp;"));
        //}

        public static string MethodMap()
        {
            return(BaseItems
                   .Select(l => "{0}:{1}".FilledWith(l.Value.QuotedForJavascript(), l.Text.QuotedForJavascript()))
                   .JoinedAsString(", ")
                   .SurroundContentWith("{", "}"));
        }
Esempio n. 2
0
 public static string AsJsonObject()
 {
     return(BaseItems
            .Select(l => "{0}:{1}"
                    .FilledWith(l.Value.ToString().QuotedForJavascript(),
                                TextFor(l).QuotedForJavascript()))
            .JoinedAsString(", ")
            .SurroundContentWith("{", "}"));
 }
Esempio n. 3
0
        //public static string DisplayVotingMethodFor(Election currentElection, Person person)
        //{
        //  //p.VotingMethod.DefaultTo(VotingMethodEnum.InPerson) == VotingMethodEnum.InPerson ? null : p.EnvNum

        //  var item = BaseItems.SingleOrDefault(i => i.Value == person.VotingMethod);
        //  if (item == null)
        //  {
        //    // unknown!
        //    return person.VotingMethod;
        //  }
        //  if (item == InPerson)
        //  {
        //    // don't show anything for In Person voters
        //    return "";
        //  }

        //  var envNum = person.EnvNum.AsInt(0);
        //  var envNumText = envNum == 0 ? "?" : envNum.ToString();

        //  if (currentElection.MaskVotingMethod.AsBoolean())
        //  {
        //    return "Envelope " + envNumText;
        //  }

        //  return string.Format("{1} <span>{0}</span> {2}", item.DisplayText, envNumText, " ".PadRight(envNumText.Length).Replace(" ", "&nbsp;"));
        //}

        public static HtmlString ForHtmlSelect(string selected = "")
        {
            return
                (BaseItems
                 .Select(bi => "<option value='{0}'{2}>{1}</option>"
                         .FilledWith(bi.Value, TextFor(bi), bi.Value == selected ? " selected" : ""))
                 .JoinedAsString()
                 .AsRawHtml());
        }
Esempio n. 4
0
        public static HtmlString ForHtmlSelect(Location location)
        {
            var selected = location == null ? "" : location.TallyStatus;

            return
                (BaseItems
                 .Select(bi => "<option value='{0}'{2}>{1}</option>"
                         .FilledWith(bi.Value, bi.Text, bi.Value == selected ? " selected" : ""))
                 .JoinedAsString()
                 .AsRawHtml());
        }
Esempio n. 5
0
 public static HtmlString ForHtmlSelect(string selected = "", Dictionary <string, string> extraAttribPerItem = null)
 {
     return
         (BaseItems
          .Select(bi => "<option value='{0}'{2}>{1}</option>"
                  .FilledWith(
                      bi.Value,
                      bi.Text,
                      (bi.Value == selected ? " selected" : "")
                      + (extraAttribPerItem != null ? extraAttribPerItem.Where(kvp => kvp.Key == bi.Value).Select(kvp => kvp.Value).SingleOrDefault() : "")))
          .JoinedAsString()
          .AsRawHtml());
 }