/// <summary> /// Update the LiveSermons object /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SystemResponse <LiveStreamingResponse> > GoLive(LiveSermonsUpdateRequest request) { // validate the request var validRequest = LiveSermonsUpdateRequest.ValidateRequest(request); if (validRequest.HasErrors) { // an error ocurred here return(new SystemResponse <LiveStreamingResponse>(true, validRequest.ErrorMessage)); } var updateLiveSermonsResponse = await _sermonsRepository.GoLive(request); if (updateLiveSermonsResponse == null) { return(new SystemResponse <LiveStreamingResponse>(true, SystemMessages.UnableToFindLiveSermon)); } // times have already been converted to UTC var response = new LiveStreamingResponse { ExpirationTime = updateLiveSermonsResponse.ExpirationTime, IsLive = updateLiveSermonsResponse.IsLive, IsSpecialEvent = updateLiveSermonsResponse.SpecialEventTimes != null ? true : false, SpecialEventTimes = updateLiveSermonsResponse.SpecialEventTimes ?? null }; return(new SystemResponse <LiveStreamingResponse>(response, "Success!")); }
/// <summary> /// returns a list of all Passage Objets /// </summary> public async Task <LiveStreamingResponse> GetLiveSermons() { var getLiveSermonsResponse = await _sermonsRepository.GetLiveSermons(); // we are not streaming so there's no need to include anything var response = new LiveStreamingResponse { IsLive = false, ExpirationTime = getLiveSermonsResponse.ExpirationTime }; // if we are currently streaming then we will need to add the slug to the middle of the Facebook link if (getLiveSermonsResponse.IsLive) { // do the business logic here friend response.IsLive = true; response.IsSpecialEvent = getLiveSermonsResponse.SpecialEventTimes != null ? true : false; response.SpecialEventTimes = getLiveSermonsResponse.SpecialEventTimes ?? null; } else { response.NextLive = getLiveSermonsResponse.NextLive; } return(response); }
/// <summary> /// Updates the LiveSermon to be a special event /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SystemResponse <LiveStreamingResponse> > UpdateLiveForSpecialEvents(LiveSermonsSpecialEventUpdateRequest request) { // validate the request var validationResponse = request.ValidateRequest(); if (validationResponse.HasErrors) { return(new SystemResponse <LiveStreamingResponse>(true, validationResponse.ErrorMessage)); } // Update this object for the requested fields var updated = new LiveSermons { ExpirationTime = request.SpecialEventTimes.End ?? new DateTime(1990, 01, 01, 11, 20, 0, 0), IsLive = true, LastUpdated = DateTime.UtcNow, SpecialEventTimes = request.SpecialEventTimes }; var updateLiveSermonsResponse = await _sermonsRepository.UpdateLiveSermons(updated); if (updateLiveSermonsResponse.HasErrors) { return(new SystemResponse <LiveStreamingResponse>(true, updateLiveSermonsResponse.ErrorMessage)); } var liveResponse = updateLiveSermonsResponse.Result; var response = new LiveStreamingResponse { ExpirationTime = liveResponse.ExpirationTime.ToUniversalTime(), IsLive = liveResponse.IsLive, IsSpecialEvent = true, SpecialEventTimes = request.SpecialEventTimes }; // we are updating this so we should watch for when it expires, when it does we will need to update Mongo DetermineIfStreamIsInactive(); return(new SystemResponse <LiveStreamingResponse>(response, "Success!")); }