本文整理汇总了C#中WebApplication1.List.Any方法的典型用法代码示例。如果您正苦于以下问题:C# List.Any方法的具体用法?C# List.Any怎么用?C# List.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebApplication1.List
的用法示例。
在下文中一共展示了List.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Grade
protected void Grade()
{
string whatTest = Request.Form["what"];
string connectionString = WebConfigurationManager.ConnectionStrings["JE-Banken"].ConnectionString;
NpgsqlConnection conn = new NpgsqlConnection(connectionString);
User u = (User)Session["user"];
int antalFragor = 0;
int antalRatt = 0;
XmlDocument doc = new XmlDocument();
List<Svar> svarList = new List<Svar>();
List<testdel> tdList = new List<testdel>();
doc.Load(MapPath("/tests/" + u.employeenumber.ToString() + ".xml"));
XmlNodeList nodeList = doc.SelectNodes("/formular/fraga");
foreach (XmlNode fraga in nodeList)
{
antalFragor++;
Svar s = new Svar();
s.del = fraga["del"].InnerText;
if (!tdList.Any(x => x.del == fraga["del"].InnerText))
{
testdel td = new testdel();
td.del = fraga["del"].InnerText;
tdList.Add(td);
}
int svarAntalRatt = 0;
int antalSvaradeRatt = 0;
foreach (XmlNode svar in fraga["svar"].ChildNodes)
{
if (Convert.ToInt32(svar.Attributes["ratt"].Value) == 1)
{
svarAntalRatt++;
}
if (Convert.ToInt32(svar.Attributes["ratt"].Value) == 1 && Convert.ToInt32(svar.Attributes["gissat"].Value) == 1)
{
antalSvaradeRatt++;
}
}
if (svarAntalRatt == antalSvaradeRatt)
{
antalRatt++;
s.ratt = true;
}
svarList.Add(s);
}
Response.Write("<h2 class='antalRatt'>Antal poäng: " + antalRatt + "/" + antalFragor + "</h2>");
Response.Write("<div class='responseHidden'></div>");
foreach (testdel td in tdList)
{
foreach (Svar s in svarList)
{
if (s.del == td.del)
{
td.antalFragor++;
if (s.ratt)
{
td.antalRatt++;
}
}
}
}
string score = antalRatt.ToString() + "/" + antalFragor.ToString();
bool passed = false;
bool totalpassed = false;
bool testpartpassed = true;
if ((Convert.ToDouble(antalRatt) / Convert.ToDouble(antalFragor)) >= 0.7)
{
totalpassed = true;
}
foreach (testdel td in tdList)
{
if ((Convert.ToDouble(td.antalRatt) / Convert.ToDouble(td.antalFragor)) < 0.6)
{
testpartpassed = false;
// 1 = knowledgetest
// 0 = licensetest
if (whatTest != "1")
{
string sql2 = "UPDATE employees SET licensed = @licensed WHERE employeenumber=" + u.employeenumber;
NpgsqlCommand cmd2 = new NpgsqlCommand(sql2, conn);
cmd2.Parameters.AddWithValue("licensed", false);
conn.Open();
cmd2.ExecuteScalar();
conn.Close();
}
//.........这里部分代码省略.........
示例2: IsOwnerOf
/// <summary>Checks whether the current user is the owner of the item with the specified Id.</summary>
/// <param name="itemId">The Id of the item in question.</param>
/// <returns>True if the user owns the item, false if not.</returns>
public static bool IsOwnerOf(int itemId)
{
List<Item> items = new List<Item>(GetOwnedFileInfosByEmail(_sessionUser.Email));
items.AddRange(GetOwnedPackagesByEmail(_sessionUser.Email));
return items.Any<Item>(item => item.Id == itemId);
}