Example #1
0
        public async Task <ActionResult <PartialTemplate> > CreateAsync(PartialTemplate template)
        {
            template.Creator = User.Identity.Name;
            var created = await _templateService.Create(template);

            return(Ok(created));
        }
Example #2
0
        public async Task <IActionResult> UpdateAsync(string id, PartialTemplate templateIn)
        {
            templateIn.Editor = User.Identity.Name;

            await _templateService.Update(id, templateIn);

            return(NoContent());
        }
Example #3
0
        public async Task <PartialTemplate> Create(PartialTemplate template)
        {
            var dbPartial = template.AsEntity();
            await _store.Partials.AddAsync(dbPartial).ConfigureAwait(false);

            await _store.SaveChangesAsync().ConfigureAwait(false);

            return(dbPartial.AsDomain());
        }
Example #4
0
        public async Task Update(string id, PartialTemplate template)
        {
            var dbPartial = await _store.Partials.FindAsync(Guid.Parse(id)).ConfigureAwait(false);

            var dbPartialNew = template.AsEntity();

            _store.Partials.Attach(dbPartial);
            _store.Entry(dbPartial).CurrentValues.SetValues(dbPartialNew);
            await _store.SaveChangesAsync();
        }
Example #5
0
        public async Task <PartialTemplate> Create(PartialTemplate template)
        {
            if (string.IsNullOrWhiteSpace(template.Id))
            {
                template.Id = Guid.NewGuid().ToString("N").ToLower();
            }
            var created = await _templates.Create(template);

            await _cache.Appand("partials", new PartialCacheItem { Id = created.Id, Template = created.TemplateBody });

            return(template);
        }
Example #6
0
        public async Task Update(string id, PartialTemplate template)
        {
            var old = await _templates.Get(id);

            if (old == null)
            {
                throw new Exception("Template not found!");
            }
            template.Updated = DateTime.UtcNow.AsDate();
            await _templates.Update(id, template);

            await _cache.Remove("partials", id);

            await _cache.Appand("partials", new PartialCacheItem { Id = template.Id, Template = template.TemplateBody });
        }
Example #7
0
 public async Task Update(string id, PartialTemplate template) => await _users.ReplaceOneAsync(template => template.Id == id, template);
Example #8
0
        public async Task <PartialTemplate> Create(PartialTemplate template)
        {
            await _users.InsertOneAsync(template);

            return(template);
        }