本文整理汇总了C#中PetaPoco.Database.Exists方法的典型用法代码示例。如果您正苦于以下问题:C# PetaPoco.Database.Exists方法的具体用法?C# PetaPoco.Database.Exists怎么用?C# PetaPoco.Database.Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PetaPoco.Database
的用法示例。
在下文中一共展示了PetaPoco.Database.Exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fbLogin
private void fbLogin(HttpContext context)
{
string token = context.Request.Params["token"];
Facebook.FacebookClient client = new Facebook.FacebookClient(token);
//client.Post()
client.UseFacebookBeta = client.IsSecureConnection = true;
Facebook.JsonObject o = (Facebook.JsonObject)client.Get("/me");
var db = new PetaPoco.Database(Common.HairStyleConnectionString, "System.Data.SqlClient");
using (var scope = db.GetTransaction())
{
try
{
string first_name = (string)o["first_name"];
string name = (string)o["name"];
decimal id = Convert.ToDecimal(o["id"]);
POCOS.Facebook fb = new POCOS.Facebook();
fb.name = name;
fb.first_name = first_name;
fb.gender = (string)o["gender"];
fb.id = id;
fb.last_name = (string)o["last_name"];
fb.link = (string)o["link"];
fb.locale = (string)o["locale"];
fb.timezone = Convert.ToDouble(o["timezone"]);
string updatedtime = (string)o["updated_time"];
DateTime dt;
if (DateTime.TryParse(updatedtime, out dt))
fb.updated_time = dt;
if (db.Exists<POCOS.Facebook>(id))
db.Update(fb);
else
db.Insert(fb);
POCOS.AppUser au = POCOS.AppUser.FirstOrDefault("Select top 1 * from AppUsers where [email protected]", id);
if (au == null)
{
au = new POCOS.AppUser();
au.FirstName = first_name;
au.facebookid = id;
db.Insert(au);
}
scope.Complete();
CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false);
CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false);
}
finally
{
scope.Dispose();
}
}
}