本文整理汇总了C#中UserService.ApproveFriendRequest方法的典型用法代码示例。如果您正苦于以下问题:C# UserService.ApproveFriendRequest方法的具体用法?C# UserService.ApproveFriendRequest怎么用?C# UserService.ApproveFriendRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService.ApproveFriendRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
UserService se = new UserService(new UserRepository());
se.ApproveFriendRequest(new ChatAppService.Models.FriendRequest()
{
FromUserId = "89",
ToUserId ="0"
});
var jGcmData = new JObject();
var jData = new JObject();
jData.Add("message", MESSAGE);
jGcmData.Add("to", "/topics/global");
jGcmData.Add("data", jData);
var url = new Uri("https://gcm-http.googleapis.com/gcm/send");
try
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.TryAddWithoutValidation(
"Authorization", "key=" + API_KEY);
Task.WaitAll(client.PostAsync(url,
new StringContent(jGcmData.ToString(), Encoding.Default, "application/json"))
.ContinueWith(response =>
{
Console.WriteLine(response);
Console.WriteLine("Message sent: check the client device notification tray.");
Console.ReadLine();
}));
}
}
catch (Exception e)
{
Console.WriteLine("Unable to send GCM message:");
Console.Error.WriteLine(e.StackTrace);
}
}
示例2: linkBtnAddFriend_Click
protected void linkBtnAddFriend_Click(object sender, EventArgs e)
{
try
{
using (UserService service = new UserService())
{
LinkButton button = ((LinkButton)sender);
if (button.CommandName == "Approve")
{
FriendRequest request = new FriendRequest();
request.FromUserId = button.CommandArgument;
request.ToUserId = LoggedUser.ID;
service.ApproveFriendRequest(request);
FailureText.Text = "Approved Successfully..";
}
}
}
catch (Exception ex)
{
throw ex;
}
}