master
wet 3 years ago
parent 647e3975cc
commit 14b92855ac

@ -14,11 +14,7 @@ namespace djy.Paas.IService
/// </summary>
public interface IAmsService:IsBase
{
/// <summary>
///保存单据
/// </summary>
/// <returns></returns>
public void SaveInfo(AMSSaveDto dto);
}

@ -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<AMS_Master>();
using (var transaction = dapper.BeginTransaction(dapper.GetConn()))
{
master.CreateTime = DateTime.Now;
var gid = await dapper.InsertByEntityAsync(master);
transaction.Rollback();
}
}
}
}

@ -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<AMS_Master>();
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;
}
}
}
}

Loading…
Cancel
Save