|
@@ -186,20 +186,42 @@ FROM
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- if (dto.Status == 1)
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+
|
|
|
+
|
|
|
+ Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
|
|
|
+ res_InvitationData.Country = dto.Country;
|
|
|
+ res_InvitationData.City = dto.Area;
|
|
|
+ res_InvitationData.UnitName = dto.Client;
|
|
|
+ res_InvitationData.Delegation = dto.DiId.ToString();
|
|
|
+ res_InvitationData.Address = dto.Address;
|
|
|
+ res_InvitationData.CreateUserId = dto.CreateUserId;
|
|
|
+ res_InvitationData.Contact = dto.Contact;
|
|
|
+ res_InvitationData.Job = dto.Job;
|
|
|
+ res_InvitationData.Tel = dto.Tel;
|
|
|
+ res_InvitationData.Field = dto.Field;
|
|
|
+
|
|
|
+ Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
|
|
|
+ (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
|
|
|
+
|
|
|
+ if (ifNullUp == null)
|
|
|
+ {
|
|
|
+ int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- _sqlSugar.BeginTran();
|
|
|
+ res_InvitationData.Id = ifNullUp.Id;
|
|
|
+ await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>(res_InvitationData).ExecuteCommandAsync();
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if (dto.Status == 1)
|
|
|
+ {
|
|
|
var res_InvitationOfficial = await _sqlSugar.Queryable< Res_OfficialActivities >().FirstAsync(x=>x.Client == dto.Client && x.Address == dto.Address && x.IsDel == 0 && x.DiId == dto.DiId);
|
|
|
|
|
|
if (res_InvitationOfficial != null)
|
|
|
{
|
|
|
_sqlSugar.RollbackTran();
|
|
|
- return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
-
|
|
|
+ result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -209,44 +231,12 @@ FROM
|
|
|
if (id == 0)
|
|
|
{
|
|
|
_sqlSugar.RollbackTran();
|
|
|
- return result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
|
|
|
- res_InvitationData.Country = dto.Country;
|
|
|
- res_InvitationData.City = dto.Area;
|
|
|
- res_InvitationData.UnitName = dto.Client;
|
|
|
- res_InvitationData.Delegation = dto.DiId.ToString();
|
|
|
- res_InvitationData.Address = dto.Address;
|
|
|
- res_InvitationData.CreateUserId = dto.CreateUserId;
|
|
|
- res_InvitationData.Contact = dto.Contact;
|
|
|
- res_InvitationData.Job = dto.Job;
|
|
|
- res_InvitationData.Tel = dto.Tel;
|
|
|
-
|
|
|
- Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
|
|
|
- (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
|
|
|
-
|
|
|
- if (ifNullUp == null)
|
|
|
- {
|
|
|
- int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
|
|
|
- if (DataID != 0)
|
|
|
- {
|
|
|
- _sqlSugar.CommitTran();
|
|
|
- return new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _sqlSugar.RollbackTran();
|
|
|
- return new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
- }
|
|
|
+ result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_sqlSugar.CommitTran();
|
|
|
- result.Code = 0;
|
|
|
- result.Msg = "添加成功!";
|
|
|
- return result;
|
|
|
+ result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -279,16 +269,24 @@ FROM
|
|
|
Remark = dto.Remark,
|
|
|
IsSubmitApproval = dto.IsSubmitApproval,
|
|
|
});
|
|
|
- if (!res)
|
|
|
+ if (res)
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
}
|
|
|
- return result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
public async Task<Result> PostReqReqSampleTips(string country, string Area,string client)
|