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); }
/// <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) { }
/// <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)) { }
/// <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) { }
/// <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())); }