示例#1
0
 public ActionResult SubmitPoll(FormCollection fm)
 {
     string str = fm["TopicIDjson"];
     if (base.Request.Cookies["votetopic"] != null)
     {
         return base.Content("isnotnull");
     }
     if (string.IsNullOrWhiteSpace(str))
     {
         return base.Content("false");
     }
     Maticsoft.BLL.Poll.PollUsers users = new Maticsoft.BLL.Poll.PollUsers();
     Maticsoft.Model.Poll.PollUsers model = new Maticsoft.Model.Poll.PollUsers();
     int num = users.Add(model);
     if (num < 0)
     {
         return base.Content("false");
     }
     Maticsoft.Model.Poll.UserPoll poll = new Maticsoft.Model.Poll.UserPoll();
     Maticsoft.BLL.Poll.UserPoll poll2 = new Maticsoft.BLL.Poll.UserPoll();
     poll.UserIP = base.Request.UserHostAddress;
     poll.UserID = num;
     foreach (JsonObject obj2 in JsonConvert.Import<JsonArray>(str))
     {
         int num2 = Globals.SafeInt(obj2["topicid"].ToString(), 0);
         string text = obj2["topicvlaue"].ToString();
         int num3 = Globals.SafeInt(obj2["type"].ToString(), -1);
         poll.TopicID = new int?(num2);
         switch (num3)
         {
             case 0:
             {
                 poll.OptionID = new int?(Globals.SafeInt(text, -1));
                 poll2.Add(poll);
                 continue;
             }
             case 1:
             {
                 poll.OptionIDList = text;
                 if (!string.IsNullOrWhiteSpace(text))
                 {
                     poll2.Add2(poll);
                 }
                 continue;
             }
             case 2:
             {
                 continue;
             }
         }
     }
     HttpCookie cookie = new HttpCookie("votetopic");
     cookie.Values.Add("voteid", "votetopic");
     cookie.Expires = DateTime.Now.AddHours(240.0);
     base.Response.Cookies.Add(cookie);
     return base.Content("true");
 }