public IAggregateRoot Handle(CreateTemplate command) { var template = Template.CreateNew(command, _validator); _templateRepository.Create(template); return(template); }
public IEnumerable <IEvent> Handle(CreateTemplate command) { var template = Template.CreateNew(command, _validator); _templateRepository.Create(template); return(template.Events); }
public async Task Create(AddTemplateViewModel model) { var template = new Template(); template.Body = model.Body; template.Subject = model.Subject; await _repo.Create(template); }
public ActionResult <Result <bool> > CreateTemplate([FromBody] CreateTemplateRQ body) { if (string.IsNullOrEmpty(body.Name)) { return(Result <bool> .Fail($"Name cannot be empty.")); } var templateExists = _templateRepo.TemplateExists(body.Name); if (templateExists) { return(Result <bool> .Fail($"Template '{body.Name}' already exists.")); } var newDbName = NameHelper.TemplateName(); var alreadyRegistered = _templateRepo.DatabaseRegisteredAsTemplate(newDbName); if (alreadyRegistered) { return(Result <bool> .Fail($"Generated name is already used for another template. Please try again.")); } var existsOnSqlServer = _microsoftSQLService.DatabaseExists(newDbName); if (existsOnSqlServer) { return(Result <bool> .Fail($"Generated name is not unique. Please try again.")); } var dbCreateSuccess = _microsoftSQLService.CreateDatabase(newDbName, true); if (!dbCreateSuccess) { return(Result <bool> .Fail($"Failed to create databse '{newDbName}' on database server")); } var success = _templateRepo.Create(body.Name, newDbName, UserId); if (success) { return(Result <bool> .Success(true)); } else { return(Result <bool> .Fail("Failed to save changes.")); } }
public async Task <object> Create([FromBody] EmailTemplate emailTemplate) { try { emailTemplate.Content = EmailHelper.Base64Encode(emailTemplate.Content); emailTemplate = _templateRepository.Create(emailTemplate); } catch (Exception ex) { result = false; error = ex.Message; } return(new SingleResponse <EmailTemplate> { Message = "Email template created successfully", DidError = false, ErrorMessage = string.Empty, Token = string.Empty, Model = emailTemplate }); }
public async Task <Template> Create(Template template) { if (string.IsNullOrWhiteSpace(template.Id)) { template.Id = Guid.NewGuid().ToString("N").ToLower(); } template.Version = "v1"; //template.Versions = new Models.Version[] { new Models.Version { VersionNumber = "v1", Created = DateTime.Now, Creator = "system", TemplateBody = template.TemplateBody } }; var created = await _templates.Create(template); if (!(await _categories.Exists(template.Category))) { await _categories.Create(new Category { Id = Guid.NewGuid(), Name = template.Category, Description = template.Category }); } await _cache.Set(template.ToCacheKey(), created); return(template); }
public void Create(T item) { _repo.Create(item); }