/// <summary>
        /// Called when the activity is created.
        /// </summary>
        /// <param name="activity">The activity.</param>
        /// <param name="savedInstanceState">State of the saved instance.</param>
        public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
        {
            if (!ReferenceEquals(activity, _activity))
            {
                return;
            }

            var eventArgs = new ActivityEventArgs(activity);

            ActivityCreated.SafeInvoke(this, eventArgs);
        }
Beispiel #2
0
        public async Task HandleAsync(CreateActivity command)
        {
            Console.WriteLine($"Creating activity: {command.Name}");

            var activityCreated = new ActivityCreated(
                command.Id,
                command.UserId,
                command.Category,
                command.Name,
                command.Description,
                command.CreatedAt
                );

            await _busClient.PublishAsync(activityCreated);
        }
Beispiel #3
0
 public async Task HandleAsync(CreateActivity command)
 {
     try
     {
         await _activityService.AddAsync(command.Id, command.UserId, command.Category, command.Name, command.Description, command.CreatedAt);
         var activityCreated = new ActivityCreated(command.Id, command.UserId, command.Name, command.Category, command.Description, DateTime.Now);
         await _bus.PublishAsync(activityCreated);
     }
     catch (ActionException ex)
     {
         await _bus.PublishAsync(new CreateActivityRejected(command.Id, ex.Code, ex.Message));
     }
     catch (Exception ex)
     {
         await _bus.PublishAsync(new CreateActivityRejected(command.Id, "error", ex.Message));
     }
 }
Beispiel #4
0
        public async Task HandleAsync(CreateActivity command)
        {
            Console.WriteLine($"Creating Activity : {command.Name}");
            try
            {
                await _activityService.AddAsync(command.Id, command.UserId, command.Category, command.Name,
                                                command.Description, command.CreatedAt);

                ActivityCreated created = new ActivityCreated(command.Id, command.UserId, command.Category, command.Name, command.Description, command.CreatedAt);
                await _busClient.PublishAsync(created);
            }
            catch (MicroServicesException e)
            {
                await _busClient.PublishAsync(new CreateActivityRejected(command.Id.ToString(), e.Message, e.Code));
            }
            catch (Exception e)
            {
                await _busClient.PublishAsync(new CreateActivityRejected(command.Id.ToString(), e.Message, "error"));
            }
        }
 public void Handle(ActivityCreated @event)
 {
     BuildViews();
 }
    /// <summary>
    ///     Called when an activity is created.
    /// </summary>
    /// <param name="activity">The activity.</param>
    /// <param name="savedInstanceState">The activity's saved instance state, if any.</param>
    public virtual void OnActivityCreated(Activity activity, Bundle savedInstanceState)
    {
        CurrentActivity = activity;

        ActivityCreated?.Invoke(this, new ActivityCreatedEventArgs(activity, savedInstanceState));
    }