コード例 #1
0
        public IHttpActionResult GetCompanyByID(string id)
        {
            CompanyEntity companyEntity = new CompanyEntity();
            ResultEntity  result        = new ResultEntity();

            try
            {
                COMPANY temp = dal.FindCompanyByID(new Guid(id));
                companyEntity = temp.ToCompanyEntity();
                if (temp.COMPANY1 != null)
                {
                    companyEntity.SubCompanies = temp.COMPANY1.ToList <COMPANY>().ConvertAll <CompanyEntity>(c => c.ToCompanyEntity());
                }
                if (temp.COMPANY2 != null)
                {
                    companyEntity.ParentCompany = temp.COMPANY2.ToCompanyEntity();
                }
                if (temp.USERs != null)
                {
                    companyEntity.Users = temp.USERs.ToList <USER>().ConvertAll <UserEntity>(u => u.ToUserEntity());
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                NtripProxyLogger.LogExceptionIntoFile("调用接口api/Company/GetCompanyByID/{id}异常,异常信息为:" + e.Message);
            }

            result.IsSuccess = result.Message == null;
            result.Data      = companyEntity;
            return(Json <ResultEntity>(result));
        }