Beispiel #1
0
        public async Task <int> CreateAsync(Guid id, Guid currentVersionId, string userId, string name, string content)
        {
            var template = new Template(id, currentVersionId, userId, name, content);
            await _templateRepository.AddAsync(template);

            return(0);
        }
        public async Task <Unit> Handle(CreateTemplateCommand request, CancellationToken cancellationToken)
        {
            var templateValue = new TemplateValue(request.descriptionValue);
            var template      = new Template(request.description, templateValue);
            await _templateRepository.AddAsync(template);

            await _templateRepository.UnityOfWork.SaveChangesAsync();

            return(await Unit.Task);
        }
Beispiel #3
0
        public async Task <Tuple <ErrorResponse, Template> > CreateAsync(Template template)
        {
            var returnedBoolValue = await repository.CheckIfNamesDuplicate(template);

            if (returnedBoolValue == true)
            {
                return(new Tuple <ErrorResponse, Template>(new ErrorResponse(400.1, $"The Template name \"{template.Name}\" is already in use."), null));
            }
            await cloudFileManager.UploadTemplateXMLFileAsync(template);

            await repository.AddAsync(template);

            await eventSourceManager.CreateTemplateEvent(template);

            return(new Tuple <ErrorResponse, Template>(null, template));
        }
Beispiel #4
0
        public async Task Save(Template template)
        {
            try
            {
                if (template.ID == default(int))
                {
                    await _repository.AddAsync(template);
                }
                else
                {
                    _repository.Update(template);
                }

                await _repository.SaveAsync();
            }
            catch (Exception ex)
            { throw ex; }
        }
 public async Task HandleAsync(TemplateCreated @event)
 {
     var template = new Template(@event.Id, @event.CurrentVersionId);
     await _templateRepository.AddAsync(template);
 }
Beispiel #6
0
 public async Task AddAsync(string name, string template)
 {
     var userId = _userResolver.GetUserId();
     await _repository.AddAsync(name, template, userId, DateTimeOffset.Now);
 }