/// <summary> /// 添加模板 /// </summary> /// <param name="tenantId"></param> /// <param name="templateDto"></param> /// <returns></returns> public virtual async Task AddTemplate(TemplateDto templateDto, int?tenantId) { var template = templateDto.MapTo <Template>(); template.TenantId = tenantId ?? AbpSession.TenantId; await Manager.InsertAsync(template); }
/// <summary> /// 设置模板 /// </summary> /// <param name="templateDto"></param> /// <param name="tenantId"></param> /// <returns></returns> public virtual async Task UpdateTemplate(TemplateDto templateDto, int?tenantId) { using (CurrentUnitOfWork.SetTenantId(tenantId ?? AbpSession.TenantId)) { var template = await Manager.GetByIdAsync(templateDto.Id); templateDto.MapTo(template); await Manager.UpdateAsync(template); } }
/// <summary> /// 设置模板 /// </summary> /// <param name="templateDto"></param> /// <param name="tenantId"></param> /// <returns></returns> public virtual async Task UpdateTemplate(TemplateDto templateDto, int?tenantId) { using (CurrentUnitOfWork.SetTenantId(tenantId ?? AbpSession.TenantId)) { Template template = null; if (templateDto.Id == 0) { template = templateDto.MapTo <Template>(); template.TenantId = tenantId ?? AbpSession.TenantId; } else { template = await Manager.GetByIdAsync(templateDto.Id); } templateDto.MapTo(template); await Manager.SaveAsync(template); } }