public void TextInitialize() { var kernel = AssemblyConfiguration.Kernel; _createScheduleCommand = kernel.Get <CreateTemplateCommand>(); _sut = kernel.Get <GetTemplatesQuery>(); }
public async Task <IActionResult> UploadDocument([FromBody] CreateTemplateCommand postDTO) { try { DocumentFile documentFile = _mapper.Map <DocumentFile>(postDTO.DocumentFile); documentFile = _apiService.DocumentUpload(documentFile, postDTO.FileByteArray); if (documentFile.DocumentPath != null) { if (await _dbService.CreateDocument(documentFile)) { return(Ok()); } else { return(StatusCode(400, "Can't create document, check if all required parameters are filled in")); } } else { return(StatusCode(400, "Can't create document, check if all required parameters are filled in")); } } catch { return(StatusCode(500)); } }
public void TestInitialize() { var commandFactory = AssemblyConfiguration.Kernel.Get <CommandFactory>(); var queryFactory = AssemblyConfiguration.Kernel.Get <QueryFactory>(); _createTemplateCommand = commandFactory.GetInstance <CreateTemplateCommand>(); _getTemplateQuery = queryFactory.GetInstance <GetTemplatesQuery>(); _sut = commandFactory.GetInstance <UpdateTemplateCommand>(); }
/// <summary> /// Applies all changes made on the working template to the original template. /// </summary> public void ApplyChanges() { if (string.IsNullOrEmpty(workTemplate.Name)) { throw new NShapeException("The template's name must not be empty."); } if (TemplateWasChanged) { ICommand cmd = null; switch (editMode) { case TemplateControllerEditMode.CreateTemplate: cmd = new CreateTemplateCommand(workTemplate); project.ExecuteCommand(cmd); // after inserting the template into the cache, the template becomes the new // originalTemplate and a new workTemplate has to be cloned. // TemplateControllerEditMode is changed from Create to Edit so the user can continue editing the // template until the template editor is closed originalTemplate = workTemplate; // ToDo: Set appropriate DisplayService originalTemplate.Shape.DisplayService = null; workTemplate = originalTemplate.Clone(); editMode = TemplateControllerEditMode.EditTemplate; break; case TemplateControllerEditMode.EditTemplate: // set workTemplate.Shape's DisplayService to the original shape's DisplayService // (typically the ToolSetController) workTemplate.Shape.DisplayService = originalTemplate.Shape.DisplayService; if (workTemplate.Shape.Type != originalTemplate.Shape.Type) { cmd = new ExchangeTemplateShapeCommand(originalTemplate, workTemplate); } else { cmd = new CopyTemplateFromTemplateCommand(originalTemplate, workTemplate); } project.ExecuteCommand(cmd); break; default: throw new NShapeUnsupportedValueException(typeof(TemplateControllerEditMode), editMode); } TemplateWasChanged = false; if (ApplyingChanges != null) { ApplyingChanges(this, EventArgs.Empty); } } }
public async Task <IActionResult> CreateTemplate([FromBody] CreateTemplateCommand command) { try { string orgEmail = JwtClaim.GetEmail(User); UserTemplateDTO createdTemplate = await this._service.Create(orgEmail, command); return(Created("template/", createdTemplate._tid)); } catch (Exception e) { this._logger.LogError(e, e.Message); return(StatusCode(500)); } }
public async Task <UserTemplateDTO> Create(string email, CreateTemplateCommand command) { try { Organization org = await this._orgService.GetByEmail(email); UserTemplate template = new UserTemplate(org, command.attributes); UserTemplate createdTemplate = await this._repo.Create(template); org.associateTemplate(createdTemplate); await this._orgService.Update(org); UserTemplateDTO dto = new UserTemplateDTO(createdTemplate._tid, createdTemplate.attributes); return(dto); } catch (Exception) { throw new Exception("Internal error creating a User Template"); } }
public TemplatesModule(IDocumentStore documentStore, CreateTemplateCommand createTemplateCommand) : base("templates/{type}") { _documentStore = documentStore; Post["/"] = call => { var model = this.Bind<ServiceEndpoints.Templates.CreateUnsubscribeTemplate>(); createTemplateCommand.Body = model.Body; createTemplateCommand.Type = Enum.Parse(typeof(TemplateType), call.type, true); createTemplateCommand.Execute(); return Response.AsText("OK"); }; Get["/"] = call => { using (var session = _documentStore.OpenSession()) { var type = (TemplateType)Enum.Parse(typeof(TemplateType), call.type, true); return Response.AsJson(session.Query<Template>().Where(q => q.Type == type).ToList()); } }; }
/// <summary> /// Applies all changes made on the working template to the original template. /// </summary> public void ApplyChanges() { if (string.IsNullOrEmpty(workTemplate.Name)) throw new NShapeException("The template's name must not be empty."); if (TemplateWasChanged) { ICommand cmd = null; switch (editMode) { case TemplateControllerEditMode.CreateTemplate: cmd = new CreateTemplateCommand(workTemplate); project.ExecuteCommand(cmd); // after inserting the template into the cache, the template becomes the new // originalTemplate and a new workTemplate has to be cloned. // TemplateControllerEditMode is changed from Create to Edit so the user can continue editing the // template until the template editor is closed originalTemplate = workTemplate; // ToDo: Set appropriate DisplayService originalTemplate.Shape.DisplayService = null; workTemplate = originalTemplate.Clone(); editMode = TemplateControllerEditMode.EditTemplate; break; case TemplateControllerEditMode.EditTemplate: // set workTemplate.Shape's DisplayService to the original shape's DisplayService // (typically the ToolSetController) workTemplate.Shape.DisplayService = originalTemplate.Shape.DisplayService; if (workTemplate.Shape.Type != originalTemplate.Shape.Type) cmd = new ExchangeTemplateShapeCommand(originalTemplate, workTemplate); else cmd = new CopyTemplateFromTemplateCommand(originalTemplate, workTemplate); project.ExecuteCommand(cmd); break; default: throw new NShapeUnsupportedValueException(typeof (TemplateControllerEditMode), editMode); } TemplateWasChanged = false; if (ApplyingChanges != null) ApplyingChanges(this, EventArgs.Empty); } }
public Task CreateTemplate(CreateTemplateCommand command) { return(_mediator.Send(command)); }
public void TestInitialize() { var factory = AssemblyConfiguration.Kernel.Get <CommandFactory>(); _sut = factory.GetInstance <CreateTemplateCommand>(); }
public async Task <IActionResult> Create([FromForm] CreateTemplateCommand command) { await Mediator.Send(command); return(NoContent()); }