Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the code a little bit #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/OutgoingWebhook/Controllers/MessagesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Activity GetMessage([FromBody]Activity activity)
var authResult = _teamsAuth.Validate(this.Request);
if (!authResult.AuthSuccessful)
{
return new Activity()
return new Activity
{
Text = "You are not authorized to call into this endpoint."
};
Expand All @@ -33,7 +33,7 @@ public Activity GetMessage([FromBody]Activity activity)
if (activity.Text.Contains("hero", StringComparison.InvariantCultureIgnoreCase))
{
var card = CreateSampleHeroCard();
attachment = new Attachment()
attachment = new Attachment
{
ContentType = HeroCard.ContentType,
Content = card
Expand All @@ -42,7 +42,7 @@ public Activity GetMessage([FromBody]Activity activity)
else if (activity.Text.Contains("thumbnail", StringComparison.InvariantCultureIgnoreCase))
{
var card = CreateSampleThumbnailCard();
attachment = new Attachment()
attachment = new Attachment
{
ContentType = ThumbnailCard.ContentType,
Content = card
Expand All @@ -51,35 +51,35 @@ public Activity GetMessage([FromBody]Activity activity)

if (attachment != null)
{
return new Activity()
return new Activity
{
Attachments = new List<Attachment>() { attachment }
};
}

return new Activity()
return new Activity
{
Text = "Try to type <b>hero</b> or <b>thumbnail</b>."
};
}

private HeroCard CreateSampleHeroCard()
{
return new HeroCard()
return new HeroCard
{
Title = "Superhero",
Subtitle = "An incredible hero",
Text = "Microsoft Teams",
Images = new List<CardImage>()
Images = new List<CardImage>
{
new CardImage()
new CardImage
{
Url = "https://github.com/tony-xia/microsoft-teams-templates/raw/master/images/cbd_after_sunset.jpg"
}
},
Buttons = new List<CardAction>()
Buttons = new List<CardAction>
{
new CardAction()
new CardAction
{
Type = "openUrl",
Title = "Visit",
Expand All @@ -91,20 +91,20 @@ private HeroCard CreateSampleHeroCard()

private ThumbnailCard CreateSampleThumbnailCard()
{
return new ThumbnailCard()
return new ThumbnailCard
{
Title = "Teams Sample",
Subtitle = "Outgoing Webhook sample",
Images = new List<CardImage>()
Images = new List<CardImage>
{
new CardImage()
new CardImage
{
Url = "https://github.com/tony-xia/microsoft-teams-templates/raw/master/images/steak.jpg"
}
},
Buttons = new List<CardAction>()
Buttons = new List<CardAction>
{
new CardAction()
new CardAction
{
Type = "openUrl",
Title = "Visit",
Expand Down