예제 #1
0
        public async Task <IActionResult> Get([FromQuery] ImageRequest request)
        {
            if (_imageUtility.ImageHash(request.Image) != request.Hash)
            {
                throw new SlackException("Invalid validation hash");
            }
            var model = _imageUtility.DeserializeImage(request.Image);

            var(image, mimeType) = await _service.Render(model);

            return(File(image, mimeType));
        }
예제 #2
0
        private Notification BuildNotificationFromTemplate(string templateName, NotificationType type, Person recipient, Announcement announcement = null
                                                           , Guid?applicationId = null, MarkingPeriod markingPeriod = null, PrivateMessage privateMessage = null, Person asker = null, object other = null, string baseUrl = null)
        {
            var parameters = new List <string> {
                GetBaseUrlByRole(recipient, baseUrl)
            };
            var notification = new NotificationDetails
            {
                PersonRef = recipient.Id,
                Person    = recipient,
                RoleRef   = recipient.RoleRef,
                Shown     = false,
                Type      = type,
                Created   = serviceLocator.Context.NowSchoolTime
            };

            if (announcement != null)
            {
                notification.AnnouncementRef = announcement.Id;
                notification.Announcement    = announcement;
            }
            if (applicationId.HasValue)
            {
                //notification.Application = application;
                notification.ApplicationRef = applicationId;
            }
            if (markingPeriod != null)
            {
                notification.MarkingPeriod    = markingPeriod;
                notification.MarkingPeriodRef = markingPeriod.Id;
            }
            if (privateMessage != null)
            {
                notification.PrivateMessage    = privateMessage;
                notification.PrivateMessageRef = privateMessage.Id;
            }
            if (asker != null)
            {
                notification.QuestionPerson    = asker;
                notification.QuestionPersonRef = asker.Id;
                parameters.Add(GetRelativeUrlByRole(asker));
            }

            var    model   = new { Notification = notification, Other = other };
            string message = RenderService.Render(templateName, model, parameters);

            notification.Message = message;
            return(notification);
        }