An alternative to UBB.threads
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
FLocal/FLocal.IISHandler/handlers/request/CreatePollHandler.cs

47 lines
1.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Web.Core;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.request {
class CreatePollHandler : AbstractPostHandler {
protected override string templateName {
get {
return "result/PollCreated.xslt";
}
}
protected override XElement[] Do(WebContext context) {
string title = context.httprequest.Form["title"].Trim();
if(title == "") throw new FLocalException("title is empty");
string[] rawOptions = context.httprequest.Form.GetValues("option");
List<string> options = new List<string>();
foreach(string rawOption in rawOptions) {
if(rawOption != null && rawOption.Trim() != "") {
options.Add(rawOption.Trim());
}
}
if(options.Count < 2) throw new FLocalException("Only " + options.Count + " options is entered");
bool isDetailed = context.httprequest.Form.AllKeys.Contains("isDetailed");
bool isMultiOption = context.httprequest.Form.AllKeys.Contains("isMultiOption");
Poll poll = Poll.Create(
context.session.account.user,
isDetailed,
isMultiOption,
title,
options
);
return new XElement[] {
poll.exportToXml(context),
};
}
}
}