public ApiResult <UserModel> SaveTestFileData(TestPostFileArgs args) { var result = new UserModel() { Id = 1, Name = $"SaveTestFileData {args.UserId} company: {args.CompanyId}, file length: {args.CompanyFile.Length}" }; byte[] bytes = new byte[args.CompanyFile.Length]; using (var stream = args.CompanyFile.OpenReadStream()) { stream.Read(bytes, 0, (int)args.CompanyFile.Length); } using (var tran = UnitOfWork.BeginTransaction()) { _attachmentService.CreateAttachment(UnitOfWork, args.UserId, args.CompanyFile.FileName, bytes, tran); UnitOfWork.SaveChanges(); tran.Commit(); } return(ApiResult.Success(result)); }