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()); }
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)); }
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()); }
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 })); }
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)); }
public static TopicTemplate ToEntity(this TopicTemplateModel model) { return(model.MapTo <TopicTemplateModel, TopicTemplate>()); }