public async Task <bool> UpdateEventAsync(Guid eventId, EventWriteModel eventWriteModel) { using (var session = _sessionFactory.CreateCommandSession()) { var affected = await session.ExecuteAsync(new UpdateEventCommand(eventId, eventWriteModel)); session.Commit(); return(affected != 0); } }
public async Task <Event> SaveEventAsync(EventWriteModel eventWriteModel) { var insertEventCommand = new InsertEventCommand(eventWriteModel); using (var session = _sessionFactory.CreateCommandSession()) { await session.ExecuteAsync(insertEventCommand); session.Commit(); } return(insertEventCommand.Event); }
public InsertEventCommand(EventWriteModel eventWriteModel) { var @event = new Event { EventId = Guid.NewGuid(), PartnerId = eventWriteModel.PartnerId, EventName = eventWriteModel.EventName, AddressLine1 = eventWriteModel.AddressLine1, PostalCode = eventWriteModel.PostalCode, City = eventWriteModel.City, Country = eventWriteModel.Country, Latitude = eventWriteModel.Latitude, Longitude = eventWriteModel.Longitude, CreatedAt = DateTime.UtcNow, OccursOn = eventWriteModel.OccursOn, }; EventWriteModel = eventWriteModel; Event = @event; }
protected async Task <Guid> PostNewEventAsync(DateTime starts, DateTime ends, string location) { var newEvent = new EventWriteModel { Name = "TestEvent", Starts = starts, Ends = ends, Location = location }; var content = JsonConvert.SerializeObject(newEvent); var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); var response = await Client.PostAsync("api/event", stringContent); response.EnsureSuccessStatusCode(); var newId = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); Console.WriteLine($"String to parse: {newId}"); return(new Guid(newId)); }
public UpdateEventCommand(Guid eventId, EventWriteModel eventWriteModel) { EventId = eventId; EventWriteModel = eventWriteModel; }