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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 public UpdateEventCommand(Guid eventId, EventWriteModel eventWriteModel)
 {
     EventId         = eventId;
     EventWriteModel = eventWriteModel;
 }