private void NewTemplateMenuItem_Click(object sender, EventArgs e) { using (EditTemplate dialog = new EditTemplate(this.Project)) { if (dialog.ShowDialog() == DialogResult.OK) { string newTemplateFilePath = Configuration.CodeBase + "\\Resources\\Templates\\NewTemplate.xslt"; try { //If they are creating a new file, copy the template over. if (!File.Exists(dialog.Template.XsltAbsolutePath)) { if (File.Exists(newTemplateFilePath)) { File.Copy(newTemplateFilePath, dialog.Template.XsltAbsolutePath); } else { File.Create(dialog.Template.XsltAbsolutePath).Dispose(); } } } catch (Exception ex) { MessageBox.Show("An error occurred while creating the new template file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Project.Templates.Add(dialog.Template); RefreshTemplatesNode(); } } }
public override void CreateEditControls(IDotvvmRequestContext context, DotvvmControl container) { if (EditTemplate == null) { throw new DotvvmControlException(this, "EditTemplate must be set, when editting is allowed in a GridView."); } EditTemplate.BuildContent(context, container); }
public async Task <IHtmlContent> InvokeEdit(ContextualizedHelpers helpers, ModelExpression expression) { if (EditTemplate == null) { return(new HtmlString(string.Empty)); } return(await EditTemplate.Invoke(expression, this, helpers)); }
private void EditMenuItem_Click(object sender, EventArgs e) { using (EditTemplate dialog = new EditTemplate(this.Template)) { if (dialog.ShowDialog() == DialogResult.OK) { UpdateNode(); } } }
public async Task <IHtmlContent> InvokeEdit(object o, ContextualizedHelpers helpers, string overridePrefix = null) { if (EditTemplate == null) { return(new HtmlString(string.Empty)); } return(await EditTemplate.Invoke(new ModelExpression( combinePrefixes(AdditionalPrefix, For.Name), For.ModelExplorer.GetExplorerForModel(o)), this, helpers, overridePrefix)); }
public async Task <IHtmlContent> InvokeEdit(object o, string prefix, ContextualizedHelpers helpers) { if (EditTemplate == null) { return(new HtmlString(string.Empty)); } //await PrerenderInLineColumnTemplates(o, prefix, helpers); return(await EditTemplate.Invoke( new ModelExpression(prefix, For.ModelExplorer.GetExplorerForModel(o)), this, helpers)); }
public void EditView_Template_Test() { var template = new EditTemplate(new EntityInfo() { Id = _entityId }, ApplicationId); var output = template.TransformText(); Assert.NotNull(output); Assert.NotEmpty(output); Assert.Contains($"@model {ApplicationId}.Backend.DataModels.{_entityId}", output); }
public void TestMethod1() { DbConnection dbConn = new DbConnection(); dbConn.connect(); Admin textbox = new Admin(); textbox.Id = 53; textbox.Textbox1 = "Edit 1"; textbox.Textbox2 = "Edit 2"; textbox.Textbox3 = "Edit 3"; textbox.Textbox4 = "Edit 4"; textbox.Textbox5 = "Edit 5"; textbox.Textbox6 = "Edit 6"; textbox.Textbox7 = "Edit 7"; EditTemplate edtTem = new EditTemplate(); int resp = edtTem.editData(dbConn.getConn(), textbox); Assert.IsNotNull(resp); }
private void TransformViews(SmartAppInfo manifest) { var enabledEntities = manifest.DataModel.Entities.Where(e => !e.IsAbstract); foreach (var entity in enabledEntities) { var applicationId = manifest.Id; var createTemplate = new CreateTemplate(entity, applicationId); var editTemplate = new EditTemplate(entity, applicationId); var detailTemplate = new DetailsTemplate(entity, applicationId); var deleteTemplate = new DeleteTemplate(entity, applicationId); var indexTemplate = new IndexTemplate(entity, applicationId); _writingService.WriteFile(Path.Combine(_context.BasePath, createTemplate.OutputPath, entity.Id, "Create.cshtml"), createTemplate.TransformText()); _writingService.WriteFile(Path.Combine(_context.BasePath, editTemplate.OutputPath, entity.Id, "Edit.cshtml"), editTemplate.TransformText()); _writingService.WriteFile(Path.Combine(_context.BasePath, deleteTemplate.OutputPath, entity.Id, "Delete.cshtml"), deleteTemplate.TransformText()); _writingService.WriteFile(Path.Combine(_context.BasePath, detailTemplate.OutputPath, entity.Id, "Details.cshtml"), detailTemplate.TransformText()); _writingService.WriteFile(Path.Combine(_context.BasePath, indexTemplate.OutputPath, entity.Id, "Index.cshtml"), indexTemplate.TransformText()); } }
public void EditView_Template_NullParameter_Test() { var template = new EditTemplate(null, null); Assert.Throws <ArgumentNullException>(() => template.TransformText()); }