Click here to Skip to main content
15,895,746 members
Articles / Web Development / ASP.NET

Architecture Guide: ASP.NET MVC Framework + N-tier + Entity Framework and Many More

Rate me:
Please Sign up or sign in to vote.
4.88/5 (217 votes)
21 Nov 2013CPOL40 min read 1.3M   38.5K   710  
If you want to use ASP.NET MVC framework but is strugling to get things arrange to confidently use for your next business project. This Article is just for you. The article guide you to use ASP.NET MVC framework to architect a small Document Management System.
using System;
using System.Configuration;
using System.Web;

namespace MvcDemo.Common
{
	/// <summary>
	/// This Class is used to read configuration settings from the app.config file.
	/// </summary>
	public sealed class ConfigSettings
	{
        static LogManager logger = new LogManager();
		#region Constants

		/// <summary>
		/// Database connection string.
		/// </summary>
		public const string DB_CONNECTION_STRING = "DBConnectionString";

		/// <summary>
		/// Key uses to fetch the Database Provider. "SQL, Oracle, etc..."
		/// </summary>
		public const string DB_PROVIDER = "DBProvider";

		#endregion

		#region Constructors

		public ConfigSettings()
		{
		}

		#endregion

		#region Public Methods

		/// <summary>
		/// Reads the given configuration value from the app.config. 
		/// If the key does not exists then returns the default value.
		/// </summary>
		/// <param name="key">Configuration key to be read.</param>
		/// <param name="defaultValue">Default value of the key.</param>
		/// <returns></returns>
		public static string ReadConfigValue(string key, string defaultValue)
		{
			string configValue;
			
			try
			{
                configValue =  ConfigurationManager.AppSettings[key];
                if (configValue == null)
                    configValue = defaultValue;
			}
			catch// (Exception ex)
			{
				configValue = defaultValue;
			}

			return configValue;
		}

        /// <summary>
        /// Read the query string values of from the URL
        /// </summary>
        /// <param name="key">KEY to be searched for</param>
        /// <param name="val">value to be copied to </param>
        /// <returns>True return if the operation is successful, else a 'false' returns</returns>
        public static bool GetQueryStringValue(string key, out short val)
        {
            try
            {
                val = 0;
                string strVal = HttpContext.Current.Request.QueryString.Get(key);
                if (!string.IsNullOrEmpty(strVal))
                {
                    if (short.TryParse(strVal, out val)) return true;
                }
            }
            catch (System.Exception e)
            {
                logger.LogError(logger.GetType(), e);
                val = 0;
                return false;
            }
            return false;
        }

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Virtusa Pvt. Ltd.
Sri Lanka Sri Lanka
In-depth coverage of Microsoft .Net, Cloud and many other cutting-edge Technologies.

- The Mandelbrot set – someone has called it the thumb-print of God – is one of the most beautiful and remarkable discoveries in the entire history of mathematics. My profile picture is generated with that equation.

You may contact Nirosh for Consultations, Code Reviews and Architecture Guide Workshops via c_nir*o*sh@hotmail.com (Remove * to use)



View Nirosh L.W.C.'s profile on LinkedIn


Other Links

Comments and Discussions