Example #1
0
        public async Task <IActionResult> PostMyEvents([FromBody] PublishDto request)
        {
            var @event = request.ToEvent(App.Id, $"users/{UserId:notEmpty}");

            await eventPublisher.PublishAsync(@event, HttpContext.RequestAborted);

            return(NoContent());
        }
Example #2
0
        public IHttpActionResult SetConfirmation(PublishDto dto)
        {
            try
            {
                AlertDto alert = new AlertDto();


                var result = Confirmation.Pending;
                switch (dto.Confirmation)
                {
                case 0:
                    result           = Confirmation.Pass;
                    alert.AlertClass = "success";
                    alert.AlertText  = "Δημοσιευμένη";
                    break;

                case 1:
                    result           = Confirmation.Pending;
                    alert.AlertClass = "warning";
                    alert.AlertText  = "Εκκρεμών";
                    break;

                case 2:
                    result           = Confirmation.Cancel;
                    alert.AlertClass = "danger";
                    alert.AlertText  = "Απορριφθείσα";
                    break;
                }

                var confirm = _ctx.Houses
                              .Find(dto.Id);

                confirm.IsConfirmed = result;
                _ctx.SaveChanges();

                return(Ok(alert));
            }

            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #3
0
        public static async Task Main(string[] args)
        {
            var client =
                NotifoClientBuilder.Create()
                .SetApiKey(ApiKey)
                .SetApiUrl("https://*****:*****@squidex.io", Id = userId
                    };

                    await client.Users.PostUsersAsync(AppId, new UpsertUsersDto
                    {
                        Requests = new List <UpsertUserDto>
                        {
                            request
                        },
                    });
                }

                Console.WriteLine("Generated Users...");
            }

            if (args?.Contains("--subscriptions") == true)
            {
                Console.WriteLine("Generating Subscriptions...");

                foreach (var userId in users)
                {
                    var request = new SubscriptionDto {
                        TopicPrefix = TopicPrefix
                    };

                    await client.Users.PostSubscriptionAsync(AppId, userId, request);
                }

                Console.WriteLine("Generated Subscriptions...");
            }

            if (args?.Contains("--no-events") != true)
            {
                Console.WriteLine("Generating Events...");

                for (var i = 0; i < 1; i++)
                {
                    var request = new PublishDto
                    {
                        Topic = Topic
                    };

                    var formatting = new NotificationFormattingDto
                    {
                        Body = new LocalizedText
                        {
                            ["en"] = "Hello Body {{var}}",
                            ["de"] = "Hallo Body {{var}}"
                        },
                        Subject = new LocalizedText
                        {
                            ["en"] = "Hello Title {{var}}",
                            ["de"] = "Hallo Title {{var}}"
                        }
                    };

                    request.Properties = new EventProperties
                    {
                        ["var"] = "123"
                    };

                    request.Preformatted = formatting;

                    request.Timestamp = DateTimeOffset.UtcNow;

                    await client.Events.PostEventsAsync(AppId, new PublishManyDto
                    {
                        Requests = new List <PublishDto>
                        {
                            request
                        }
                    });
                }

                Console.WriteLine("Generated Events...");
            }
        }