/// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> TopicTemplateUpdate(TopicTemplateModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(ErrorJson(ModelState.SerializeErrors()));
            }

            //try to get a topic template with the specified id
            var template = await _topicTemplateService.GetTopicTemplateByIdAsync(model.Id)
                           ?? throw new ArgumentException("No template found with the specified id");

            template = model.ToEntity(template);
            await _topicTemplateService.UpdateTopicTemplateAsync(template);

            return(new NullJsonResult());
        }
Exemple #2
0
        /// <summary>
        /// Get topic template view path
        /// </summary>
        /// <param name="topicTemplateId">Topic template identifier</param>
        /// <returns>View path</returns>
        public virtual async Task <string> PrepareTemplateViewPathAsync(int topicTemplateId)
        {
            var template = await _topicTemplateService.GetTopicTemplateByIdAsync(topicTemplateId) ??
                           (await _topicTemplateService.GetAllTopicTemplatesAsync()).FirstOrDefault();

            if (template == null)
            {
                throw new Exception("No default template could be loaded");
            }

            return(template.ViewPath);
        }