Example #1
0
        // GET api/contactapi/5
        public CCustContact Get(int id)
        {
            var user = (CSign)HttpContext.Current.Session[ConfigurationManager.AppSettings["AuthSaveKey"]];

            if (user == null)
            {
                throw new HttpResponseException(new SiginFailureMessage());
            }
            using (var dal = DalBuilder.CreateDal(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, 0))
            {
                CCustContact custContact;
                try
                {
                    dal.Open();
                    custContact = CustContactBll.Get(dal, id);
                    dal.Close();
                }
                catch (Exception ex)
                {
                    LogBll.Write(dal, new CLog
                    {
                        LogUser    = string.Format("{0}-{1}", user.UserCode, user.UserName),
                        LogContent = string.Format("{0}#{1}", "CustContact.Get", ex.Message),
                        LogType    = LogType.系统异常
                    });
                    throw new HttpResponseException(new SystemExceptionMessage());
                }
                if (custContact == null)
                {
                    throw new HttpResponseException(new DataNotFoundMessage());
                }
                return(custContact);
            }
        }