public async Task<IActionResult> Execute(ContentArgs args) { if (!_Validator.IsValid(args)) { _Logger.LogWarning("Bad request."); return new BadRequestResult(); } _Logger.LogDebug("Writing DB."); await _InsertDbCommand.Execute(args); _Logger.LogDebug("Committing."); _DbContext.SaveAndCommit(); _Logger.LogInformation("Committed."); return new OkResult(); }
public bool IsValid(ContentArgs args) { if (args == null) { return(false); } if (!ContentTypes.IsValid(args.ContentType)) { return(false); } if (!IsValidJson(args.Json)) { return(false); } return(true); }
public async Task Execute(ContentArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } var contentBytes = Encoding.UTF8.GetBytes(args.Json); var e = new ContentEntity { Created = _DateTimeProvider.Snapshot, Release = args.Release, Type = args.ContentType, PublishingId = _PublishingIdService.Create(contentBytes), Content = await _SignedFormatter.SignedContentPacket(contentBytes), ContentTypeName = MediaTypeNames.Application.Zip }; await _DbContext.Content.AddAsync(e); }