public async Task Should_Save_Template() { var command = EmailFaker.GenerateTemplateViewModel().Generate(); var result = await _emailAppService.SaveTemplate(command); result.Should().BeTrue(becauseArgs: _notifications.GetNotificationsByKey()); _database.Templates.FirstOrDefault(f => f.Name == command.Name).Should().NotBeNull(); }
public async Task <ActionResult <TemplateViewModel> > SaveTemplate([FromBody] TemplateViewModel command) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(ModelStateErrorResponseError()); } await _emailAppService.SaveTemplate(command); var newTemplate = await _emailAppService.GetTemplate(command.Name); return(ResponsePost(nameof(GetTemplate), new { name = command.Name }, newTemplate)); }