Пример #1
0
        public async Task ExecuteAsync(SendNotification command)
        {
            command.Notification.Status = NotificationInfo.NotificationStatus.New;
            await _repository.Add(command.Notification);

            command.Notification.Status = NotificationInfo.NotificationStatus.Sent;
            await _eventsPublisher.PublishAsync(new NewNotificationCreated { Notification = command.Notification });
        }
Пример #2
0
        public object Post(Notify model)
        {
            object json;

            try
            {
                var posted = repository.Add(model);

                if (posted != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = posted,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        success = false
                    };
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }