安邦工具箱培训数据接收接口
This commit is contained in:
@@ -238,5 +238,90 @@ namespace WebAPI.Controllers
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
[HttpPost]
|
||||
public Model.ResponeData AddUnit([FromBody] Model.UnitItem unit)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
Model.Base_Unit newUnit = db.Base_Unit.FirstOrDefault(x => x.CollCropCode == unit.CollCropCode);
|
||||
if (newUnit == null)
|
||||
{
|
||||
newUnit = new Model.Base_Unit
|
||||
{
|
||||
UnitId = SQLHelper.GetNewID(typeof(Model.Base_Unit))
|
||||
};
|
||||
db.Base_Unit.InsertOnSubmit(newUnit);
|
||||
newUnit.UnitCode = unit.UnitCode;//代码
|
||||
newUnit.UnitName = unit.UnitName;//名称
|
||||
newUnit.Corporate = unit.Corporate;//法人代表
|
||||
newUnit.Address = unit.Address;//地址
|
||||
newUnit.Telephone = unit.Telephone;//电话
|
||||
newUnit.ShortUnitName = unit.ShortUnitName;//单位简称
|
||||
newUnit.Fax = unit.Fax;//传真
|
||||
newUnit.EMail = unit.EMail;//邮箱
|
||||
|
||||
newUnit.IsBranch = unit.IsBranch;//是否分公司
|
||||
newUnit.ProjectRange = unit.ProjectRange;//工程范围
|
||||
newUnit.IsChina = unit.IsChina;//是否中国企业
|
||||
newUnit.CollCropCode = unit.CollCropCode;//社会统一信用代码
|
||||
newUnit.LinkName = unit.LinkName;//联系人姓名
|
||||
if (!string.IsNullOrEmpty(unit.IdcardType))
|
||||
{
|
||||
var basicData = db.RealName_BasicData.FirstOrDefault(x => x.DictTypeCode == "ZHENGJIAN_TYPE" && x.DictName == unit.IdcardType);
|
||||
if (basicData != null)
|
||||
{
|
||||
newUnit.IdcardType = basicData.DictCode;//联系人证件类型 (香港永久性身份证 军官证 其他 警官证 台湾居民身份证 身份证 护照)
|
||||
}
|
||||
}
|
||||
newUnit.IdcardNumber = unit.IdcardNumber;//联系人证件号
|
||||
newUnit.LinkMobile = unit.LinkMobile;//联系人电话
|
||||
newUnit.CollCropStatus = unit.CollCropStatus;//是否黑名单企业
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(unit.ProjectId))
|
||||
{
|
||||
Model.Project_ProjectUnit projectUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.UnitId == newUnit.UnitId && x.ProjectId == unit.ProjectId);
|
||||
if (projectUnit == null)
|
||||
{
|
||||
projectUnit = new Model.Project_ProjectUnit();
|
||||
projectUnit.ProjectUnitId = SQLHelper.GetNewID(typeof(Model.Base_Unit));
|
||||
db.Project_ProjectUnit.InsertOnSubmit(projectUnit);
|
||||
|
||||
projectUnit.ProjectId = unit.ProjectId;
|
||||
projectUnit.UnitId = newUnit.UnitId;
|
||||
projectUnit.InTime = DateTime.Now;
|
||||
|
||||
if (!string.IsNullOrEmpty(unit.UnitTypeId))
|
||||
{
|
||||
var unitTypeList = (from x in Funs.DB.Sys_Const
|
||||
where x.GroupId == ConstValue.Group_ProjectUnitType
|
||||
orderby x.SortIndex
|
||||
select x).ToList();
|
||||
var unitType = unitTypeList.FirstOrDefault(x => x.ConstText == unit.UnitTypeId);
|
||||
if (unitType != null)
|
||||
{
|
||||
projectUnit.UnitType = unitType.ConstValue;// 单位类型(监理 施工分包 安装 其他 业主 检测单位 其他 总包)
|
||||
}
|
||||
}
|
||||
//projectUnit.UnitType = newUnit.UnitTypeId;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
responeData.data = newUnit.UnitId;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
return responeData;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user