diff --git a/ams/djy.Paas.IService/Ams/IAmsService.cs b/ams/djy.Paas.IService/Ams/IAmsService.cs index 4ebf59e..a5b8da4 100644 --- a/ams/djy.Paas.IService/Ams/IAmsService.cs +++ b/ams/djy.Paas.IService/Ams/IAmsService.cs @@ -14,11 +14,7 @@ namespace djy.Paas.IService /// public interface IAmsService:IsBase { - /// - ///保存单据 - /// - /// - public void SaveInfo(AMSSaveDto dto); + } diff --git a/ams/djy.paas.Service/Ams/AmsService.cs b/ams/djy.paas.Service/Ams/AmsService.cs index 70c9459..f157ed0 100644 --- a/ams/djy.paas.Service/Ams/AmsService.cs +++ b/ams/djy.paas.Service/Ams/AmsService.cs @@ -20,24 +20,12 @@ namespace djy.Service.Ams public class AmsService : ServBase, IAmsService { - DapperDBBase dapper = new DapperDBBase(); + public async void SaveInfo(AMSSaveDto dto) { - AMS_Master master = dto.MapTo(); - - using (var transaction = dapper.BeginTransaction(dapper.GetConn())) - { - master.CreateTime = DateTime.Now; - var gid = await dapper.InsertByEntityAsync(master); - - transaction.Rollback(); - - - - - } + } } } diff --git a/ams/djy.Model/AmsDto/AMSDto.cs b/ams/djyweb_djyPaasApi/AmsDto/AMSDto.cs similarity index 100% rename from ams/djy.Model/AmsDto/AMSDto.cs rename to ams/djyweb_djyPaasApi/AmsDto/AMSDto.cs diff --git a/ams/djyweb_djyPaasApi/Controllers/AMS/AmsController.cs b/ams/djyweb_djyPaasApi/Controllers/AMS/AmsController.cs index 78c101e..24d6688 100644 --- a/ams/djyweb_djyPaasApi/Controllers/AMS/AmsController.cs +++ b/ams/djyweb_djyPaasApi/Controllers/AMS/AmsController.cs @@ -1,9 +1,11 @@ using AMSDto; using Common; +using djy.Model.Ams; using djy.Service; using djy.Service.Ams; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Shared.Repository; using System; namespace djy_AmsApi.Controllers @@ -11,25 +13,41 @@ namespace djy_AmsApi.Controllers [AllowAnonymous] public class AmsController : ApiBase { - + DapperDBBase dapper = new DapperDBBase(); AmsService ser =new AmsService(); [HttpPost("Add")] public Response Add(AMSSaveDto Dto) { var result = new Response(); - try - { + + AMS_Master master = Dto.MapTo(); + using (var transaction = dapper.BeginTransaction(dapper.GetConn())) + { + try + { + + + - ser.SaveInfo(Dto); - } - catch (Exception ex) - { - result.Code = 500; - result.Message = ex.InnerException?.Message ?? ex.Message; - } + + master.CreateTime = DateTime.Now; + var gid = dapper.InsertByEntityAsync(master); + + } + catch (Exception ex) + { + transaction.Rollback(); + result.Code = 500; + result.Message = ex.InnerException?.Message ?? ex.Message; + } + } return result; } + + + + } } -} +