private static async Task RecordProposal(IBinder binder, DialogSubmissionPayload proposalPayload) { var proposals = await binder.GetTableCollector <Proposal>("proposals"); var proposal = new Proposal { PartitionKey = proposalPayload.PartitionKey, RowKey = proposalPayload.ActionTimestamp, ProposedBy = proposalPayload.User.Id, Team = proposalPayload.Team.Id, Channel = proposalPayload.Channel.Id, Name = proposalPayload.GetValue("name"), Part = 1, Url = proposalPayload.GetValue("url"), Notes = proposalPayload.GetValue("notes") }; await proposals.AddAsync(proposal); await SlackHelper.PostMessage(binder, proposalPayload.Team.Id, new PostMessageRequest { Text = $"<@{proposalPayload.User.Id}> vient de proposer un vidéo :", Channel = proposalPayload.Channel.Id, Attachments = new [] { new MessageAttachment { Title = proposal.GetFormattedTitle(), Text = proposal.Notes, Footer = "Utilisez /edu:list pour voir toutes les propositions", Color = "#1d7c00" } } }); await binder.RecordChannelActivity(proposalPayload.Team.Id, proposalPayload.Channel.Id); }
public static async Task <MessageAttachment> GetProposalAttachment(IBinder binder, Proposal proposal, bool allowActions = true) { var attachment = new MessageAttachment { AuthorName = $"Proposé par <@{proposal.ProposedBy}>", Title = proposal.GetFormattedTitle(), Text = proposal.Notes, Color = "#1d7c00" }; if (allowActions) { Plan plan = null; if (!String.IsNullOrWhiteSpace(proposal.PlannedIn)) { plan = await binder.GetTableRow <Plan>("plans", proposal.PartitionKey, proposal.PlannedIn); } if (plan == null) { attachment.CallbackId = "proposal_action"; attachment.Actions = new List <MessageAction> { new MessageAction { Type = "button", Name = "delete", Text = "Supprimer", Value = proposal.RowKey, Style = "danger", Confirm = new ActionConfirmation { Title = "Supprimer la proposition", Text = $"Voulez-vous vraiment supprimer la proposition \"{proposal.Name}\" ?", OkText = "Supprimer", DismissText = "Annuler" } } }; } else { attachment.Footer = $"Planifié pour le {plan.Date:dddd d MMMM}."; } } return(attachment); }
public static async Task <MessageAttachment> GetPlanAttachment(IBinder binder, Plan plan) { Proposal proposal = null; if (!String.IsNullOrWhiteSpace(plan.Video)) { var proposals = await binder.GetTable("proposals"); proposal = await proposals.Retrieve <Proposal>(plan.PartitionKey, plan.Video); } var result = new MessageAttachment { PreText = $"*Le {plan.Date:dddd d MMMM}*", Color = "#004492", Fields = new List <AttachmentField> { new AttachmentField { Title = "Responsable", Value = String.IsNullOrWhiteSpace(plan.Owner) ? "À déterminer" : $"<@{plan.Owner}>", Short = true }, new AttachmentField { Title = "Video", Value = proposal == null ? "À déterminer" : proposal.GetFormattedTitle(), Short = true } }, CallbackId = "plan_action" }; if (String.IsNullOrWhiteSpace(plan.Owner)) { result.Actions.Add( new MessageAction { Type = "button", Name = "volunteer", Value = plan.RowKey, Text = "Je m'en occupe", Confirm = new ActionConfirmation { Title = "Confirmer", Text = "Vous confirmez que vous êtes responsable de ce Lunch & Watch ?", OkText = "Oui!", DismissText = "Oups, non" } } ); } if (String.IsNullOrWhiteSpace(plan.Video) && plan.Date <= DateTime.Now.AddDays(7)) { result.Actions.Add( new MessageAction { Type = "button", Name = "vote", Value = plan.RowKey, Text = "Voter pour le vidéo" }); result.Footer = $"Le vote se termine le {plan.Date:d MMMM} à 11h."; } return(result); }