예제 #1
0
        public virtual ActionResult TopicTemplateUpdate(TopicTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = _topicTemplateService.GetTopicTemplateById(model.Id);

            if (template == null)
            {
                throw new ArgumentException("No template found with the specified id");
            }
            template = model.ToEntity(template);
            _topicTemplateService.UpdateTopicTemplate(template);

            return(new NullJsonResult());
        }
예제 #2
0
        public virtual IActionResult TopicTemplateAdd(TopicTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            TopicTemplate template = new TopicTemplate();

            template = model.ToEntity(template);
            _topicTemplateService.InsertTopicTemplate(template);

            return(new NullJsonResult());
        }
 public IActionResult TopicTemplateAdd(TopicTemplateModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Json(new DataSourceResult {
             Errors = ModelState.SerializeErrors()
         }));
     }
     if (ModelState.IsValid)
     {
         var template = new TopicTemplate();
         template = model.ToEntity(template);
         _topicTemplateService.InsertTopicTemplate(template);
         return(new NullJsonResult());
     }
     return(ErrorForKendoGridJson(ModelState));
 }
예제 #4
0
        public virtual IActionResult TopicTemplateUpdate(TopicTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

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

            template = model.ToEntity(template);
            _topicTemplateService.UpdateTopicTemplate(template);

            return(new NullJsonResult());
        }
예제 #5
0
        public virtual IActionResult TopicTemplateAdd(TopicTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = new TopicTemplate();

            template = model.ToEntity(template);
            _topicTemplateService.InsertTopicTemplate(template);

            return(Json(new { Result = true }));
        }
예제 #6
0
        public virtual ActionResult TopicTemplateAdd([Bind(Exclude = "Id")] TopicTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = new TopicTemplate();

            template = model.ToEntity(template);
            _topicTemplateService.InsertTopicTemplate(template);

            return(new NullJsonResult());
        }
        /// <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());
        }
        public IActionResult TopicTemplateUpdate(TopicTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = _topicTemplateService.GetTopicTemplateById(model.Id);

            if (template == null)
            {
                throw new ArgumentException("No template found with the specified id");
            }
            if (ModelState.IsValid)
            {
                template = model.ToEntity(template);
                _topicTemplateService.UpdateTopicTemplate(template);
                return(new NullJsonResult());
            }
            return(ErrorForKendoGridJson(ModelState));
        }
 public static TopicTemplate ToEntity(this TopicTemplateModel model, TopicTemplate destination)
 {
     return(model.MapTo(destination));
 }
예제 #10
0
 public static TopicTemplate ToEntity(this TopicTemplateModel model)
 {
     return(model.MapTo <TopicTemplateModel, TopicTemplate>());
 }