private void CommandConfiguration() { Commands = new List <SessionCommand> { new BaseCommand("Name", new TextResponse($"Set event name{Emoji.Pointer}", ResponseStatus.Expect), r => { Event.SetName(r.Command); return(new TextResponse(Emoji.CheckMark, ResponseStatus.Close)); }), new BaseCommand("Description", new TextResponse($"Set event description{Emoji.Pointer}", ResponseStatus.Expect), r => { Event.SetDescription(r.Command); return(new TextResponse(Emoji.CheckMark, ResponseStatus.Close)); }), new SetDateTimeCommand("Start time", d => Event.SetStaringTime(d)), new SetDateTimeCommand("End time", d => Event.SetEndingTime(d)), new SetTimeSpanCommand("First Reminder", span => Event.SetFirstReminder(span)), new SetTimeSpanCommand("Second Reminder", span => Event.SetSecondReminder(span)), new BaseCommand("Exit", null, r => { Event = null; return(new TextResponse("Exit", ResponseStatus.Abort)); }, false), new BaseCommand("Save", null, r => { if (Event.Name == null || Name.Length == 0) { return(new TextResponse(Emoji.CrossMark + "Add event name", ResponseStatus.Exception)); } EventStorage.Add(Event); return(new TextResponse(Emoji.CheckMark, ResponseStatus.Abort)); }, false) }.ToDictionary(x => x.Name, x => x); }
public void Should_add_an_Event() { _eventStorage.Add(_eventDto); _eventRepositoryMock.Verify(r => r.Add( It.Is <Event>( c => c.Name == _eventDto.Name && c.Description == _eventDto.Description ) )); }
/// <summary> /// Handles posting a SenseEvent object, adding it to the local JSON event storage for the corresponding session. /// </summary> /// <param name="senseEvent">The SenseEvent object to store.</param> /// <returns>An IHttpActionResult object.</returns> public IHttpActionResult PostEvent(SenseEvent senseEvent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // save the latest frame capture to disk for the current session ID Imaging.SaveImage(senseEvent.SessionId, senseEvent.Capture); // remove the frame capture data from the event object senseEvent.Capture = null; // save the rest of the event data EventStorage.Add(senseEvent); return(Ok()); }
/// <summary> /// Helper function to get all of the event handlers for the Freezable and /// place them in the calledHandlers list. /// <param name="calledHandlers"> Where to place the change handlers for the Freezable. </param> /// </summary> private void GetHandlers(ref EventStorage calledHandlers) { if (Freezable_UsingSingletonHandler) { if (calledHandlers == null) { calledHandlers = GetEventStorage(); } calledHandlers.Add(SingletonHandler); } else if (Freezable_UsingHandlerList) { if (calledHandlers == null) { calledHandlers = GetEventStorage(); } FrugalObjectList<EventHandler> handlers = HandlerList; for (int i = 0, count = handlers.Count; i < count; i++) { calledHandlers.Add(handlers[i]); } } }
public IActionResult Save(EventDto e) { _eventStorage.Add(e); return(Ok()); }