public void Delete_Template() { var viewModel = new TemplateViewModel {Name = Guid.NewGuid().ToString()}; var step1 = FlowFactory.TemplateFlows.CreateTemplate(viewModel); var step2 = FlowFactory.TemplateFlows.DeleteTemplate(viewModel); var workflow = new Sequence(step1, step2); workflow.Execute(_visitor); }
public ActionResult Save(TemplateViewModel templateViewModel) { if (this.ModelState.IsValid) { int? templateId = null; if (templateViewModel.Id != 0) { templateId = templateViewModel.Id; } this._cmsService.SaveTemplate(templateId, templateViewModel.Name, templateViewModel.Html); return this.RedirectToRoute(CMSAreaRegistration.CmsTemplatesRouteUrl); } TemplatePageViewModel viewModel = new TemplatePageViewModel(this._website, templateViewModel); return View("Edit", viewModel); }
private Template FromTemplateViewModel(TemplateViewModel template) { var background = FromImageViewModel(template.Background); var overlay = FromImageViewModel(template.Overlay); return new Template() { Id = template.Id, Height = (int)template.Height, Width = (int)template.Width, Name = template.Name, Images = template.Children.Select(c => new TemplateImage() { Width = c.Width, Height = c.Height, X = c.X, Y = c.Y, Id = c.Id, TemplateId = template.Id }).ToList(), Background = background, //BackgroundId = background.Return(x => x.Id, (int?)null), Overlay = overlay, //OverlayId = overlay.Return(x => x.Id, (int?)null), IsInstaPrinterTemplate = template.IsInstaPrinterTemplate }; }
public async Task <IActionResult> CreatePost(TemplateViewModel model, string submit, string returnUrl = null) { if (!model.AdminTemplates && !await _authorizationService.AuthorizeAsync(User, Permissions.ManageTemplates)) { return(Forbid()); } if (model.AdminTemplates && !await _authorizationService.AuthorizeAsync(User, AdminTemplatesPermissions.ManageAdminTemplates)) { return(Forbid()); } ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { if (String.IsNullOrWhiteSpace(model.Name)) { ModelState.AddModelError(nameof(TemplateViewModel.Name), S["The name is mandatory."]); } else if (String.IsNullOrWhiteSpace(model.Content)) { ModelState.AddModelError(nameof(TemplateViewModel.Content), S["The content is mandatory."]); } else { var templatesDocument = model.AdminTemplates ? await _adminTemplatesManager.GetTemplatesDocumentAsync() : await _templatesManager.GetTemplatesDocumentAsync() ; if (templatesDocument.Templates.ContainsKey(model.Name)) { ModelState.AddModelError(nameof(TemplateViewModel.Name), S["A template with the same name already exists."]); } } } if (ModelState.IsValid) { var template = new Template { Content = model.Content, Description = model.Description }; await(model.AdminTemplates ? _adminTemplatesManager.UpdateTemplateAsync(model.Name, template) : _templatesManager.UpdateTemplateAsync(model.Name, template) ); _notifier.Success(H["The \"{0}\" template has been created.", model.Name]); if (submit == "SaveAndContinue") { return(RedirectToAction(nameof(Edit), new { name = model.Name, adminTemplates = model.AdminTemplates, returnUrl })); } else { return(RedirectToReturnUrlOrIndex(returnUrl)); } } // If we got this far, something failed, redisplay form return(View(model)); }
private static void PrintTemplate(TemplateViewModel template) { Console.WriteLine($"DisplayName: '{template.DisplayName}', RemoteUrl: '{template.RemoteUrl}', ClonedPath: '{template.ClonedPath}', Desc: '{template.Description}'"); }
public ActionResult Preview(TemplateViewModel viewModel) { return(View(viewModel)); }
public ActionResult Create(TemplateViewModel viewModel) { _templateService.CreateTemplate(viewModel.MapTo <CreateTemplateRequest>()); return(RedirectToAction("Index")); }
public void DeleteTemplate(TemplateViewModel model) { BookingDataRepository.DeleteMasterData(model); }
public void AddTemplate(TemplateViewModel model) { BookingDataRepository.AddMasterData(model); }
/// <summary> /// Creates cliparea view model from clip area model element /// </summary> /// <param name="clipAreaElement">ClipArea model</param> /// <param name="templateViewModel">Parent template</param> /// <returns>Created cliparea view model</returns> private static ClipAreaViewModel CreateClipAreaViewModel(ClipAreaElement clipAreaElement, TemplateViewModel templateViewModel) { ClipAreaViewModel clipAreaViewModel = new ClipAreaViewModel( clipAreaElement.Name, new Rect(clipAreaElement.Left, clipAreaElement.Top, clipAreaElement.Width, clipAreaElement.Height), templateViewModel); clipAreaViewModel.JpegQuality = clipAreaElement.JpegQuality; return(clipAreaViewModel); }
/// <summary> /// Creates barcode view model from barcode model element /// </summary> /// <param name="barcode">Barcode model</param> /// <param name="templateViewModel">Parent template</param> /// <returns>Created barcode view model</returns> private static BarcodeViewModel CreateBarcodeViewModel(BarcodeElement barcode, TemplateViewModel templateViewModel) { BarcodeViewModel barcodeViewModel = new BarcodeViewModel( barcode.Name, new Rect(barcode.Left, barcode.Top, barcode.Width, barcode.Height), templateViewModel); barcodeViewModel.SelectedBarcodeType = barcode.BarcodeType; barcodeViewModel.QrVersion = barcode.QrVersion; return(barcodeViewModel); }
/// <summary> /// Creates choice box view model from choice box model /// </summary> /// <param name="choiceBox">Choice box model data</param> /// <param name="templateViewModel">Parent template</param> /// <returns>Created choice box view model</returns> private static ChoiceBoxViewModel CreateChoiceBoxViewModel(ChoiceBoxElement choiceBox, TemplateViewModel templateViewModel) { ChoiceBoxViewModel choiceBoxViewModel = new ChoiceBoxViewModel( choiceBox.Name, choiceBox.Top, choiceBox.Left, choiceBox.Width, choiceBox.Height, templateViewModel, null); foreach (OmrBubble modelBubble in choiceBox.Bubbles) { BubbleViewModel bubbleViewModel = new BubbleViewModel( choiceBox.BubbleWidth, choiceBox.BubbleHeight, modelBubble.Top - choiceBox.Top, modelBubble.Left - choiceBox.Left, choiceBoxViewModel); bubbleViewModel.Name = modelBubble.Value; bubbleViewModel.IsValid = modelBubble.IsValid; choiceBoxViewModel.Bubbles.Add(bubbleViewModel); } return(choiceBoxViewModel); }
public Task <bool> UpdateTemplate(TemplateViewModel model) { var registerCommand = _mapper.Map <UpdateTemplateCommand>(model); return(Bus.SendCommand(registerCommand)); }
public IActionResult AddTemplate(TemplateViewModel model) { return(RedirectToRoute("Index")); }