Esempio n. 1
0
        public async Task <ActionResult> PushNotification([FromBody] NotificationViewModel input)
        {
            var notification = new Notification {
                Description = input.description,
                Title       = input.title,
                Type        = input.type,
                Url         = input.url,
                Date        = DateTime.Now
            };

            _context.Add(notification);
            _context.SaveChanges();

            await PusherService.SendNotification(input, "new-notification");

            return(Ok());
        }
Esempio n. 2
0
        public async Task <IActionResult> AddNewPoll([FromBody] PollViewModel request)
        {
            var poll = new Poll
            {
                Date        = request.Date,
                Description = request.Description,
                Title       = request.Title,
                Options     = request.Options.Select(x => new Option
                {
                    Title = x.Title
                }).ToList()
            };

            _context.Add(poll);
            _context.SaveChanges();

            await PusherService.SendNotification(poll.Id, "new-poll");

            return(Ok(poll.Id));
        }