public async Task <ActionResult <PartialTemplate> > CreateAsync(PartialTemplate template) { template.Creator = User.Identity.Name; var created = await _templateService.Create(template); return(Ok(created)); }
public async Task <IActionResult> UpdateAsync(string id, PartialTemplate templateIn) { templateIn.Editor = User.Identity.Name; await _templateService.Update(id, templateIn); return(NoContent()); }
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()); }
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(); }
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); }
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 }); }
public async Task Update(string id, PartialTemplate template) => await _users.ReplaceOneAsync(template => template.Id == id, template);
public async Task <PartialTemplate> Create(PartialTemplate template) { await _users.InsertOneAsync(template); return(template); }