コード例 #1
0
        public string Get(int id)
        {
            string response;

            Account searchedAccount = DataService.GetAccountByNumber(id);

            if (searchedAccount != null)
            {
                response = JsonConvert.SerializeObject(searchedAccount, Formatting.Indented);
            }
            else
            {
                DataAccessError error = new DataAccessError("NULL_ACCOUNT", "The account searched for was not found; Search returned null.");

                response = JsonConvert.SerializeObject(error, Formatting.Indented);
            }

            return(response);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataAccessException"/> class.
 /// </summary>
 /// <param name="error">The error.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="values">The values.</param>
 internal DataAccessException(DataAccessError error, Exception innerException, params object[] values)
     : base(string.Format(GetMessage(error), values), innerException)
 {
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataAccessException"/> class.
 /// </summary>
 /// <param name="error">The error.</param>
 internal DataAccessException(DataAccessError error)
     : base(GetMessage(error))
 {
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataAccessException"/> class.
 /// </summary>
 /// <param name="error">The error.</param>
 /// <param name="innerException">The inner exception.</param>
 internal DataAccessException(DataAccessError error, Exception innerException)
     : base(GetMessage(error), innerException)
 {
 }
コード例 #5
0
 /// <summary>
 /// Gets the message.
 /// </summary>
 /// <param name="error">The error.</param>
 /// <returns></returns>
 static string GetMessage(DataAccessError error)
 {
     return(SR.ResourceManager.GetString("ERR_" + ((int)error).ToString()));
 }