public async Task <Template> Update(Guid id, [FromBody] UpdateTemplate model) { var template = await _codeGenDbContext.Templates.FindAsync(id); template.Value = model.Value; _codeGenDbContext.SaveChanges(); return(_mapper.Map <Template>(template)); }
public async Task <IActionResult> Put(Guid id, [FromBody] UpdateTemplate command) { command.Id = id; await _commandDispatcher.DispatchAsync(command); return(Created($"templates/{command.Id}", null)); }
public async Task Execute(UpdateTemplate command) { var templateDtls = writeContext.ElrSearchTemplates.Where(l => l.Id.Equals(command.TemplateId)).FirstOrDefault(); templateDtls.CdType = command.TemplateType; templateDtls.DsName = command.TemplateName; templateDtls.JsData = JsonConvert.SerializeObject(command.Criteria); await writeContext.SaveChangesAsync(); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Delimiter.Expression != null) { targetCommand.AddParameter("Delimiter", Delimiter.Get(context)); } if (PropertyNames.Expression != null) { targetCommand.AddParameter("PropertyNames", PropertyNames.Get(context)); } if (TemplateFile.Expression != null) { targetCommand.AddParameter("TemplateFile", TemplateFile.Get(context)); } if (TemplateContent.Expression != null) { targetCommand.AddParameter("TemplateContent", TemplateContent.Get(context)); } if (IncludeExtent.Expression != null) { targetCommand.AddParameter("IncludeExtent", IncludeExtent.Get(context)); } if (UpdateTemplate.Expression != null) { targetCommand.AddParameter("UpdateTemplate", UpdateTemplate.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public async Task <(Result, Template?)> UpdateAsync(Guid templateId, UpdateTemplate request, Guid userId) { var template = await _templates .Find(x => x.Id == templateId) .FirstOrDefaultAsync(); if (template is null) { return(Result.NotFound, null); } if (template.Deleted > 0) { return(Result.Gone, null); } if (template.CorrelationId == request.CorrelationId) { return(Result.Conflict, null); } _logger.LogInformation($"Trying to update template {template.Id}"); foreach (var tagName in request.Tags) { if (await _tags.CountDocumentsAsync(x => x.Key == tagName) == 0) { await _tagService.CreateAsync(new CreateTag { CorrelationId = request.CorrelationId, Key = tagName, Title = new Dictionary <string, string> { { "en", tagName } } }, userId); } } var templateUpdated = template.On(request, userId); await _templates.ReplaceOneAsync(x => x.Id == templateId, template); await _eventService.PublishAsync(templateUpdated); _logger.LogInformation($"Template {template.Id} updated"); return(Result.Successful, template); }
public override void StaticSqlStringCache(SqlModel model, Type type) { GsOperator gs = new GsOperator(typeof(SqlEntity <>), type); gs["SetPrimary"] = MebOperator.Setter(type, model.PrimaryKey); gs["Table"] = model.TableName; gs["Primary"] = model.PrimaryKey; CountTemplate count = new CountTemplate(); gs["SelectCount"] = count.SelectCount(model); gs["SelectCountWhere"] = count.SelectCountWhere(model); SelectTemplate select = new SelectTemplate(); gs["SelectAll"] = select.SelectAll(model); gs["SelectAllWhere"] = select.SelectAllWhere(model); gs["SelectAllByPrimary"] = select.SelectAllByPrimary(model); gs["SelectAllIn"] = select.SelectAllIn(model); UpdateTemplate update = new UpdateTemplate(); gs["UpdateAllWhere"] = update.UpdateWhere(model); gs["UpdateAllByPrimary"] = update.UpdateByPrimary(model); InsertTemplate insert = new InsertTemplate(); gs["InsertAll"] = insert.Insert(model); DeleteTemplate delete = new DeleteTemplate(); gs["DeleteWhere"] = delete.DeleteWhere(model); gs["DeleteByPrimary"] = delete.DeleteByPrimary(model); RepeateTemplate repeate = new RepeateTemplate(); var repeateModel = model.ModelWithAttr <NoRepeateAttribute>(); gs["RepeateCount"] = repeate.RepeateCount(repeateModel); gs["RepeateId"] = repeate.RepeateId(repeateModel); gs["RepeateEntities"] = repeate.RepeateEntities(repeateModel); }
public async Task <IActionResult> UpdateTemplate([FromBody] UpdateTemplate command) { await rules .NoDuplicateTemplateNames() .EnsureValidColumnName() .EnsureValidOperator() .Apply(command, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await elrService.Execute(command); return(Ok()); }