/// <summary> /// 创建任务流模板 /// </summary> public async Task <string> CreateAsync(TaskTemplateDto templateDto, CurrentUserDto user) { if (templateDto.Name.IsBlank()) { throw new Exception("模板名称不能为空"); } if (templateDto.Id.IsNotBlank()) { var template = await _context.TaskTemplates.FindAsync(templateDto.Id); if (template != null) { template.Name = templateDto.Name; } } else { var template = new TaskTemplateEntity { Name = templateDto.Name }; template.CreateEntity(user.UserId); template.SetStep(TaskTemplateStep.Save); await _context.AddAsync(template); templateDto.Id = template.Id; } await _context.SaveChangesAsync(); return(templateDto.Id); }
public async Task <IActionResult> Add(TaskTemplateDto template) { var templateId = await _taskTemplateService.CreateAsync(template, GetCurrentUser()); if (templateId.IsNotBlank()) { return(RedirectToAction("AddForm", new { id = templateId })); } return(View(template)); }
public virtual async Task SetTaskTemplate(TaskTemplateDto taskTemplateDto) { using (CurrentUnitOfWork.SetTenantId(taskTemplateDto.TenantId)) { var template = await TemplateManager.GetByIdAsync(taskTemplateDto.Id); template.TemplateContent = taskTemplateDto.TemplateContent; } //var tenant = await Manager.GetByIdAsync(taskTemplateDto.TenantId); //tenant.SetPropertyValue("TemplateContent", taskTemplateDto.TemplateContent); }