public async Task UpdateEventEndDate(Guid eventId, DateTime endTime) { var datetimeUtcIso8601 = endTime.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz", CultureInfo.InvariantCulture); var extendEventStatement = "UPDATE EventData SET endtime = '" + datetimeUtcIso8601 + "' WHERE EventID=" + eventId + ";"; var session = SessionCacheManager.GetSession(KeySpace); await session.ExecuteAsync((await session.PrepareAsync(extendEventStatement)).Bind()); }
public async Task <DataContract.Event> GetEvent(Guid eventId) { var query = "SELECT EventDetails from EventData WHERE EventId=" + eventId.ToString() + ";"; var sessionL = SessionCacheManager.GetSession(KeySpace); var preparedStatement = await sessionL.PrepareAsync(query); var resultSet = await sessionL.ExecuteAsync(preparedStatement.Bind()); return(JsonConvert.DeserializeObject <DataContract.Event>(resultSet.First().GetValue <string>("eventdetails"))); }
private async Task <IEnumerable <Guid> > GetEventParticipantsList(Guid eventId) { var session = SessionCacheManager.GetSession(KeySpace); var query = "SELECT UserId FROM EventParticipantMapping WHERE EventId=" + eventId.ToString() + "ALLOW FILTERING;"; var preparedStatement = await session.PrepareAsync(query); var resultSet = await session.ExecuteAsync(preparedStatement.Bind()); return(resultSet.Select(row => row.GetValue <Guid>("userid"))); }
private async Task <IEnumerable <Guid> > GetEventIdsByUserId(Guid userid) { var sessionL = SessionCacheManager.GetSession(KeySpace); var query = "SELECT EventId FROM EventParticipantMapping WHERE UserId=" + userid.ToString() + ";"; var preparedStatement = await sessionL.PrepareAsync(query); var resultSet = await sessionL.ExecuteAsync(preparedStatement.Bind()); return(resultSet.Select(row => row.GetValue <Guid>("eventid"))); }
private async Task InsertAsyncEventData(Evento @event) { var session = SessionCacheManager.GetSession(KeySpace); var eventJson = JsonConvert.SerializeObject(@event); var insertEventData = $"INSERT INTO EventData (EventId, StartTime, EndTime, EventDetails) values ({@event.Id},'{@event.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)}','{@event.EndTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)}','{eventJson}');"; var ips = await session.PrepareAsync(insertEventData); var statement = ips.Bind(); await session.ExecuteAsync(statement); }
public async Task SaveEvent(Evento @event) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } var updateParticipantStateStatement = "UPDATE EventData SET EventDetails = '" + JsonConvert.SerializeObject(@event) + "' WHERE EventID=" + @event.Id + ";"; var session = SessionCacheManager.GetSession(KeySpace); await session.ExecuteAsync((await session.PrepareAsync(updateParticipantStateStatement)).Bind()); }
private async Task <IEnumerable <DataContract.Event> > GetEventsByEventIds(IEnumerable <Guid> eventIds) { var datetimeUtcIso8601 = DateTime.UtcNow.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz", CultureInfo.InvariantCulture); var query = "SELECT EventDetails FROM EventData WHERE EventId IN (" + string.Join(",", eventIds.ToList()) + ") " + "and EndTime > '" + datetimeUtcIso8601 + "' ALLOW FILTERING;"; var sessionL = SessionCacheManager.GetSession(KeySpace); var preparedStatement = await sessionL.PrepareAsync(query); var resultSet = await sessionL.ExecuteAsync(preparedStatement.Bind()); return(resultSet.Select(row => JsonConvert.DeserializeObject <DataContract.Event>(row.GetValue <string>("eventdetails")))); }
private async Task DeleteEventParticipantMapping(Guid eventId, IEnumerable <Guid> participantIds) { var session = SessionCacheManager.GetSession(KeySpace); participantIds?.ToList().ForEach(async participant => { var deleteEventParticipantMappings = $"Delete from UserEvent where UserId ={participant} AND EventId={eventId};"; var ips = await session.PrepareAsync(deleteEventParticipantMappings); var statement = ips.Bind(); await session.ExecuteAsync(statement); }); }
private async Task InsertEventParticipantMapping(Guid eventId, IEnumerable <Guid> participantIds) { var session = SessionCacheManager.GetSession(KeySpace); participantIds?.ToList().ForEach(async participantId => { var insertEventParticipantMapping = $"INSERT INTO UserEvent (UserId ,EventId) values ({participantId},{eventId});"; var ips = await session.PrepareAsync(insertEventParticipantMapping); var statement = ips.Bind(); await session.ExecuteAsync(statement); }); }
public async Task DeleteEventParticipantMapping(Guid eventId) { var participantList = (await GetEventParticipantsList(eventId)).ToList(); var session = SessionCacheManager.GetSession(KeySpace); participantList.ForEach(async participant => { var deleteEventParticipantMappings = "Delete from EventParticipantMapping where UserId = " + participant + " AND EventId=" + eventId + ";"; var ips = await session.PrepareAsync(deleteEventParticipantMappings); var statement = ips.Bind(participant, eventId); await session.ExecuteAsync(statement); }); }
public async Task UpdateEvent(Evento @event, bool updateParticipants = false) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } if (updateParticipants) { await UpdateParticipants(@event); } var updateParticipantStateStatement = $"UPDATE EventData SET StartTime = '{@event.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)}',EndTime='{@event.EndTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)}', EventDetails = '" + JsonConvert.SerializeObject(@event) + "' WHERE EventID=" + @event.Id + ";"; var session = SessionCacheManager.GetSession(KeySpace); await session.ExecuteAsync((await session.PrepareAsync(updateParticipantStateStatement)).Bind()); }
private async Task InsertEventParticipantMapping(Evento @event) { var session = SessionCacheManager.GetSession(KeySpace); List <Guid> participantList = (await GetEventParticipantsList(@event.Id)).ToList(); participantList.ForEach(async participant => { var insertEventParticipantMapping = "INSERT INTO EventParticipantMapping " + "(UserId ,EventId)" + "values " + "(" + participant + "," + @event.Id + ");"; var ips = await session.PrepareAsync(insertEventParticipantMapping); var eventJson = JsonConvert.SerializeObject(@event); var statement = ips.Bind(); await session.ExecuteAsync(statement); }); }
public async Task DeleteAsyncEventData(Guid eventId) { var session = SessionCacheManager.GetSession(KeySpace); var eventDeleteStatement = "Delete from EventData where EventId=" + eventId + ";"; await session.ExecuteAsync((await session.PrepareAsync(eventDeleteStatement)).Bind(eventId)); }