public ApprovalTypeModel AddApprovalType(ApprovalTypeModel approvalTypeModel) { var resultSP = DB.AddApprovalType(approvalTypeModel.approvalCode, approvalTypeModel.approvalName).Select(a => new ApprovalTypeModel { approvalCode = a.approvalCode, approvalName = a.approvalName }); if (GlobalVariable.queryType == 0) { APPROVALTYPE approvalType = new APPROVALTYPE { approvalCode = approvalTypeModel.approvalCode, approvalName = approvalTypeModel.approvalName }; DB.APPROVALTYPES.Add(approvalType); DB.SaveChanges(); return(GetOneApprovalTypeByCode(approvalType.approvalCode)); } else { return(resultSP.SingleOrDefault()); } }