示例#1
0
        private async void OnSave(object sender, EventArgs e)
        {
            var eve = BindingContext as Event;

            if (String.IsNullOrWhiteSpace(eve.Label))
            {
                await DisplayAlert("Error", "Please enter the label.", "OK");

                return;
            }

            if (eve.StartDate > eve.EndDate)
            {
                await DisplayAlert("Error", "Please enter correct dates.", "OK");

                return;
            }

            if (eve.Id == 0)
            {
                await _connection.InsertAsync(eve);

                EventAdded?.Invoke(this, eve);
            }
            else
            {
                EventUpdated?.Invoke(this, eve);
            }

            await Navigation.PopAsync();
        }
示例#2
0
        /// <summary>
        /// Store the given event
        /// </summary>
        internal static async Task StoreEvent(CounterEvent counterEvent)
        {
            using (var conn = new SqlConnection("Server=localhost;Database=EventStore;Trusted_Connection=True;"))
            {
                using (var comm = conn.CreateCommand())
                {
                    comm.CommandText = "INSERT INTO EventLog (EntityType, EntityId, Version, EventType, Payload) VALUES ('Counter', @EntityId, @Version, @EventType, @Payload)";
                    comm.Parameters.AddWithValue("@EntityID", counterEvent.Id.ToGuid());
                    comm.Parameters.AddWithValue("@Version", Convert.ToInt64(counterEvent.Version));
                    comm.Parameters.AddWithValue("@EventType", counterEvent.EventCase.ToString());
                    comm.Parameters.AddWithValue("@Payload", counterEvent.GetEventPayload().ToByteArray());

                    await conn.OpenAsync().ConfigureAwait(false);

                    try
                    {
                        await comm.ExecuteNonQueryAsync().ConfigureAwait(false);

                        EventAdded?.Invoke(new object(), EventArgs.Empty);
                    }
                    catch (SqlException ex) when(ex.Number == 2627)
                    {
                        throw new CounterOutOfDateException();
                    }
                }
            }
        }
示例#3
0
 private void AddEvent(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         EventAdded.Focus();
         MemberAdded(sender, null);
     }
 }
 private void EventsContexChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         EventAdded?.Invoke(this, new EventArgs());
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         EventDeleted?.Invoke(this, new EventArgs());
     }
 }
 private void CollectionEventsChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         EventAdded?.Invoke(this, e);
     }
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         EventRemoved?.Invoke(this, e);
     }
 }
示例#6
0
 protected virtual void EventAddedToQueue()
 {
     EventAdded?.Invoke(this, EventArgs.Empty);
 }
 private void TriggerEventAdded(EventData eventData)
 {
     EventAdded?.Invoke(this, null);
 }
示例#8
0
 private void OnEventAdded(object sender) => EventAdded?.Invoke(sender, EventArgs.Empty);
 protected virtual void OnEventAdded(EventSourcingArgs <T, TKey> e)
 {
     EventAdded?.Invoke(this, e);
 }