public override Option <string> Handle(string[] messageElements, Message originalMessage) { var allEvents = AttendanceRegistry.FindAllEventNames(originalMessage.ConversationId); return(allEvents.Any() ? string.Join(Environment.NewLine, allEvents.Select(e => $"- {e}")) : "No events available"); }
protected void Application_Start() { GlobalConfiguration.Configuration.Services.Add(typeof(IExceptionLogger), new ElmahExceptionLogger()); GlobalConfiguration.Configure(WebApiConfig.Register); DatabaseConfiguration.ConfigureMapper(); AttendanceRegistry.Initialize(); }
public override Option <string> Handle(string[] messageElements, Message originalMessage) { if (messageElements.Length == 1) { return("Event name is required"); } var eventName = string.Join(" ", messageElements.Skip(1)); return(AttendanceRegistry.SetActive(originalMessage.ConversationId, eventName)); }
public override Option <string> Handle(string[] messageElements, Message originalMessage) { var result = AttendanceRegistry.FindCurrent(originalMessage.ConversationId); return(result.Match( e => { e.In(originalMessage.From.Id, originalMessage.From.Name); return $"{originalMessage.From.Name} in"; }, () => "No active event at the moment" )); }
public override Option <string> Handle(string[] messageElements, Message originalMessage) { if (messageElements.Length == 1) { return("Event name is required"); } var result = AttendanceRegistry.Start(originalMessage.ConversationId, string.Join(" ", messageElements.Skip(1))); return(result.Match(e => "Event started", m => m)); }
public override Option <string> Handle(string[] messageElements, Message originalMessage) { var result = messageElements.Length > 1 ? AttendanceRegistry.FindByName(originalMessage.ConversationId, string.Join(" ", messageElements.Skip(1))) : AttendanceRegistry.FindCurrent(originalMessage.ConversationId); return(result.Match( e => e.ToString(), () => "No event found" )); }
public override Option <string> Handle(string[] messageElements, Message originalMessage) { var result = AttendanceRegistry.FindCurrent(originalMessage.ConversationId); return(result.Match( e => { e.Out(originalMessage.From.Id, originalMessage.From.Name, messageElements.Length > 1 ? string.Join(" ", messageElements.Skip(1)) : string.Empty); return $"{originalMessage.From.Name} out"; }, () => "No active event at the moment" )); }
protected void Application_End() { AttendanceRegistry.SaveState(); }