Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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; }
        }
Ejemplo n.º 5
0
 public async Task HandleAsync(TemplateCreated @event)
 {
     var template = new Template(@event.Id, @event.CurrentVersionId);
     await _templateRepository.AddAsync(template);
 }
Ejemplo n.º 6
0
 public async Task AddAsync(string name, string template)
 {
     var userId = _userResolver.GetUserId();
     await _repository.AddAsync(name, template, userId, DateTimeOffset.Now);
 }