public async Task <IHttpActionResult> GetApplicationList()
        {
            ApplicationTable data = new ApplicationTable();

            data.action = 4;
            return(Json(new { data = await iform.ManageApplicationResp(connectionString, data) }));
        }
        public static ApplicationModel ToApplicationModel(this ApplicationTable row)
        {
            if (row == null)
            {
                return(null);
            }
            var model = row.ConvertTo <ApplicationModel>();

            return(model);
        }
        /// <summary>
        /// Setups specified table
        /// </summary>
        /// <param name="table">Table that is set</param>
        public void GoToTable(ApplicationTable table)
        {
            SideMenuActionVisible = false;

            // Set the current table
            CurrentTable = table;

            SideMenuActionVisible = true;
            CurrentPage           = ApplicationPage.Null;
            CurrentPage           = ApplicationPage.TablePage;
        }
 /// <summary>
 /// 验证申请
 /// </summary>
 /// <param name="appTable"></param>
 /// <returns></returns>
 private string CheckApplication(ApplicationTable appTable)
 {
     if (string.IsNullOrEmpty(appTable.ApplicantCardNo))
     {
         return("申请人证件号不能为空");
     }
     if (string.IsNullOrEmpty(appTable.ApplicantDept))
     {
         return("申请人单位不能为空");
     }
     if (string.IsNullOrEmpty(appTable.ApplicantName))
     {
         return("申请人姓名不能为空");
     }
     if (string.IsNullOrEmpty(appTable.ApplicantPhoneNum))
     {
         return("申请人电话不能为空");
     }
     if (string.IsNullOrEmpty(appTable.ApplicantType))
     {
         return("申请人类别不能为空");
     }
     if (string.IsNullOrEmpty(appTable.HeadPerson))
     {
         return("负责人姓名不能为空");
     }
     if (string.IsNullOrEmpty(appTable.HeadPersonPhoneNum))
     {
         return("负责人电话不能为空");
     }
     if (string.IsNullOrEmpty(appTable.HeadPersonType))
     {
         return("负责人类别不能为空");
     }
     if (string.IsNullOrEmpty(appTable.MeetingName))
     {
         return("会议名称不能为空");
     }
     if (appTable.MembersCount < 1)
     {
         return("参与人数要大于0");
     }
     return("");
 }
Exemplo n.º 5
0
        public void AddApplicant(ApplicationViewModel app)
        {
            var newdaplicant = new ApplicationTable
            {
                Applicant_IDNumber      = app.Applicant_IDNumber,
                Applicant_Name          = app.Applicant_Name,
                Applicant_Surname       = app.Applicant_Surname,
                Applicant_Date_Of_Birth = app.Applicant_Date_Of_Birth,
                Applicant_Gender        = app.Applicant_Gender,
                Application_Grade       = "Grade_8",
                Applicant_Religion      = app.Applicant_Religion,
                Applicant_Adress        = app.Applicant_Adress,
                Maths_Mark            = app.Maths_Mark,
                English_Mark          = app.English_Mark,
                ZuluHomeLanguage_Mark = app.ZuluHomeLanguage_Mark,
                status         = "Awaiting",
                Title          = app.Title,
                Parent_Name    = app.Parent_Name,
                Parent_Surname = app.Parent_Surname,
                Parent_Number  = app.Parent_Number,
                Parent_Adress  = app.Parent_Adress,
                Parent_Email   = app.Parent_Email,
            };

            uow.Repository <ApplicationTable>().Insert(newdaplicant);
            uow.Save();

            EmailViewmodel emv   = new EmailViewmodel();
            EmailBL        email = new EmailBL();



            emv.Message = "Dear Admin  :" + app.Parent_Email + "\n" +
                          "New Applicant has Submited An Application" + "\n" +
                          "Please Check Application ";
            emv.Subject = "New Applicant";
            emv.To      = "*****@*****.**"; /*"*****@*****.**"*/;
            email.SendMail(emv);
        }
Exemplo n.º 6
0
 public async Task <IEnumerable <ApplicationTable> > ManageApplicationResp(string connectionString, ApplicationTable data)
 {
     return(await formBLL.ManageApplicationBLL(connectionString, data));
 }
 public async Task <IHttpActionResult> ManageApplication(ApplicationTable data)
 {
     return(Json(await iform.ManageApplicationResp(connectionString, data)));
 }
Exemplo n.º 8
0
        public void SaveApplicationTable(ViewModels.ApplicationTableAndFieldsViewModel applicationTableAndFieldVM)
        {
            if (applicationTableAndFieldVM.ParentTableID == 0)
            {
                ApplicationTable at = new ApplicationTable();
                at.Description = applicationTableAndFieldVM.Description;
                at.LastModified = DateTime.UtcNow;
                at.LastModifiedBy = "System";
                at.RecordAdded = DateTime.UtcNow;
                at.RecordAddedBy = "System";
                at.IsDeleted = false;

                List<ApplicationTableField> l = (List <ApplicationTableField>)at.ApplicationTableFields;
                context.ApplicationTables.Add(at);
                context.SaveChanges();

                foreach (ApplicationTableField atf in l)
                {
                    atf.ApplicationTableID = at.ApplicationTableID;
                    atf.LastModified = DateTime.UtcNow;
                    atf.LastModifiedBy = "System";
                    atf.RecordAdded = DateTime.UtcNow;
                    atf.RecordAddedBy = "System";
                    atf.IsDeleted = false;
                    context.ApplicationTableFields.Add(atf);
                }
                context.SaveChanges();
            }
            else
            {
                ApplicationTable dbEntry = context.ApplicationTables.Find(applicationTableAndFieldVM.ParentTableID);
                if (dbEntry != null)
                {
                    bool SaveIsRequired = false;
                    if (applicationTableAndFieldVM.Description != dbEntry.Description)
                    {
                        SaveIsRequired = true;
                        dbEntry.Description = applicationTableAndFieldVM.Description;

                        dbEntry.LastModified = DateTime.UtcNow;
                        dbEntry.LastModifiedBy = "System";
                    }

                    foreach (ApplicationTableField atf in applicationTableAndFieldVM.ApplicationTableFields)
                    {
                        if (atf.ApplicationTableFieldID == 0)
                        {
                            SaveIsRequired = true;
                            //this is a new entry
                            atf.LastModified = DateTime.UtcNow;
                            atf.LastModifiedBy = "System";
                            atf.RecordAdded = DateTime.UtcNow;
                            atf.RecordAddedBy = "System";
                            atf.IsDeleted = false;
                            context.ApplicationTableFields.Add(atf);
                        }
                        else
                        {
                            //first we have to find the original record and compare it and see if any of the
                            //user controlled fields have changed
                            ApplicationTableField dbAtf = context.ApplicationTableFields.Find(atf.ApplicationTableFieldID);

                            if (atf.Description != dbAtf.Description || atf.FieldType != null || atf.IsAudited != dbAtf.IsAudited)
                            {
                                SaveIsRequired = true;
                                //there's been some relevant change
                                dbAtf.Description = atf.Description;
                                dbAtf.IsAudited = atf.IsAudited;

                                if (atf.FieldType != null)
                                {
                                    dbAtf.FieldType = atf.FieldType;
                                }

                                dbAtf.LastModified = DateTime.UtcNow;
                                dbAtf.LastModifiedBy = "System";

                            }
                        }
                    }

                    if (SaveIsRequired)
                    {
                        context.SaveChanges();
                    }
                }

            }
        }
Exemplo n.º 9
0
        public List <Message> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             MessageTable.GetColumnNames("[m]") +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[m_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[m_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[m_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[m_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[m_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[m_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[m_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CustomerTable.GetColumnNames("[m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTable.GetColumnNames("[m_c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[m_c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_c_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[m_c_mo]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[m_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_mo_c]") : string.Empty) +
                             " FROM [stats].[Message] AS [m] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [m_s] ON [m].[ServiceID] = [m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [m_s_a] ON [m_s].[ApplicationID] = [m_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [m_s_p] ON [m_s].[ProductID] = [m_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [m_s_m] ON [m_s].[MerchantID] = [m_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [m_s_st] ON [m_s].[ServiceTypeID] = [m_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [m_s_ust] ON [m_s].[UserSessionTypeID] = [m_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [m_s_c] ON [m_s].[FallbackCountryID] = [m_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [m_s_l] ON [m_s].[FallbackLanguageID] = [m_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [m_s_sc] ON [m_s].[ServiceConfigurationID] = [m_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [m_s_t] ON [m_s].[TemplateID] = [m_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [m_c] ON [m].[CustomerID] = [m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [m_c_u] ON [m_c].[UserID] = [m_c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [m_c_s] ON [m_c].[ServiceID] = [m_c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_c_c] ON [m_c].[CountryID] = [m_c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [m_c_l] ON [m_c].[LanguageID] = [m_c_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_c_mo] ON [m_c].[MobileOperatorID] = [m_c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_mo] ON [m].[MobileOperatorID] = [m_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_mo_c] ON [m_mo].[CountryID] = [m_mo_c].[CountryID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "customloadmany", "notfound"), "Message list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <Message>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MessageTable              mTable       = new MessageTable(query);
                ServiceTable              m_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          m_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              m_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             m_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          m_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      m_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              m_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             m_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable m_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             m_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CustomerTable             m_cTable     = (this.Depth > 0) ? new CustomerTable(query) : null;
                UserTable           m_c_uTable         = (this.Depth > 1) ? new UserTable(query) : null;
                ServiceTable        m_c_sTable         = (this.Depth > 1) ? new ServiceTable(query) : null;
                CountryTable        m_c_cTable         = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable       m_c_lTable         = (this.Depth > 1) ? new LanguageTable(query) : null;
                MobileOperatorTable m_c_moTable        = (this.Depth > 1) ? new MobileOperatorTable(query) : null;
                MobileOperatorTable m_moTable          = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable        m_mo_cTable        = (this.Depth > 1) ? new CountryTable(query) : null;

                List <Message> result = new List <Message>();
                do
                {
                    Application          m_s_aObject   = (this.Depth > 1) ? m_s_aTable.CreateInstance() : null;
                    Product              m_s_pObject   = (this.Depth > 1) ? m_s_pTable.CreateInstance() : null;
                    Merchant             m_s_mObject   = (this.Depth > 1) ? m_s_mTable.CreateInstance() : null;
                    ServiceType          m_s_stObject  = (this.Depth > 1) ? m_s_stTable.CreateInstance() : null;
                    UserSessionType      m_s_ustObject = (this.Depth > 1) ? m_s_ustTable.CreateInstance() : null;
                    Country              m_s_cObject   = (this.Depth > 1) ? m_s_cTable.CreateInstance() : null;
                    Language             m_s_lObject   = (this.Depth > 1) ? m_s_lTable.CreateInstance() : null;
                    ServiceConfiguration m_s_scObject  = (this.Depth > 1) ? m_s_scTable.CreateInstance() : null;
                    Template             m_s_tObject   = (this.Depth > 1) ? m_s_tTable.CreateInstance() : null;
                    Service              m_sObject     = (this.Depth > 0) ? m_sTable.CreateInstance(m_s_aObject, m_s_pObject, m_s_mObject, m_s_stObject, m_s_ustObject, m_s_cObject, m_s_lObject, m_s_scObject, m_s_tObject) : null;
                    User           m_c_uObject         = (this.Depth > 1) ? m_c_uTable.CreateInstance() : null;
                    Service        m_c_sObject         = (this.Depth > 1) ? m_c_sTable.CreateInstance() : null;
                    Country        m_c_cObject         = (this.Depth > 1) ? m_c_cTable.CreateInstance() : null;
                    Language       m_c_lObject         = (this.Depth > 1) ? m_c_lTable.CreateInstance() : null;
                    MobileOperator m_c_moObject        = (this.Depth > 1) ? m_c_moTable.CreateInstance() : null;
                    Customer       m_cObject           = (this.Depth > 0) ? m_cTable.CreateInstance(m_c_uObject, m_c_sObject, m_c_cObject, m_c_lObject, m_c_moObject) : null;
                    Country        m_mo_cObject        = (this.Depth > 1) ? m_mo_cTable.CreateInstance() : null;
                    MobileOperator m_moObject          = (this.Depth > 0) ? m_moTable.CreateInstance(m_mo_cObject) : null;
                    Message        mObject             = (this.Depth > -1) ? mTable.CreateInstance(m_sObject, m_cObject, m_moObject) : null;
                    result.Add(mObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "customloadmany", "exception"), "Message list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Message", "Exception while loading (custom/many) Message object from database. See inner exception for details.", ex);
            }
        }
Exemplo n.º 10
0
        protected override Message LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             MessageTable.GetColumnNames("[m]") +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[m_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[m_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[m_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[m_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[m_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[m_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[m_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CustomerTable.GetColumnNames("[m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTable.GetColumnNames("[m_c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[m_c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[m_c_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[m_c_mo]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[m_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[m_mo_c]") : string.Empty) +
                             " FROM [stats].[Message] AS [m] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [m_s] ON [m].[ServiceID] = [m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [m_s_a] ON [m_s].[ApplicationID] = [m_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [m_s_p] ON [m_s].[ProductID] = [m_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [m_s_m] ON [m_s].[MerchantID] = [m_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [m_s_st] ON [m_s].[ServiceTypeID] = [m_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [m_s_ust] ON [m_s].[UserSessionTypeID] = [m_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [m_s_c] ON [m_s].[FallbackCountryID] = [m_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [m_s_l] ON [m_s].[FallbackLanguageID] = [m_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [m_s_sc] ON [m_s].[ServiceConfigurationID] = [m_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [m_s_t] ON [m_s].[TemplateID] = [m_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [m_c] ON [m].[CustomerID] = [m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [m_c_u] ON [m_c].[UserID] = [m_c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [m_c_s] ON [m_c].[ServiceID] = [m_c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_c_c] ON [m_c].[CountryID] = [m_c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [m_c_l] ON [m_c].[LanguageID] = [m_c_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_c_mo] ON [m_c].[MobileOperatorID] = [m_c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [m_mo] ON [m].[MobileOperatorID] = [m_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [m_mo_c] ON [m_mo].[CountryID] = [m_mo_c].[CountryID] ";
                }
                sqlCmdText += "WHERE [m].[MessageID] = @MessageID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@MessageID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "loadinternal", "notfound"), "Message could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MessageTable              mTable       = new MessageTable(query);
                ServiceTable              m_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          m_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              m_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             m_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          m_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      m_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              m_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             m_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable m_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             m_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CustomerTable             m_cTable     = (this.Depth > 0) ? new CustomerTable(query) : null;
                UserTable           m_c_uTable         = (this.Depth > 1) ? new UserTable(query) : null;
                ServiceTable        m_c_sTable         = (this.Depth > 1) ? new ServiceTable(query) : null;
                CountryTable        m_c_cTable         = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable       m_c_lTable         = (this.Depth > 1) ? new LanguageTable(query) : null;
                MobileOperatorTable m_c_moTable        = (this.Depth > 1) ? new MobileOperatorTable(query) : null;
                MobileOperatorTable m_moTable          = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable        m_mo_cTable        = (this.Depth > 1) ? new CountryTable(query) : null;


                Application          m_s_aObject   = (this.Depth > 1) ? m_s_aTable.CreateInstance() : null;
                Product              m_s_pObject   = (this.Depth > 1) ? m_s_pTable.CreateInstance() : null;
                Merchant             m_s_mObject   = (this.Depth > 1) ? m_s_mTable.CreateInstance() : null;
                ServiceType          m_s_stObject  = (this.Depth > 1) ? m_s_stTable.CreateInstance() : null;
                UserSessionType      m_s_ustObject = (this.Depth > 1) ? m_s_ustTable.CreateInstance() : null;
                Country              m_s_cObject   = (this.Depth > 1) ? m_s_cTable.CreateInstance() : null;
                Language             m_s_lObject   = (this.Depth > 1) ? m_s_lTable.CreateInstance() : null;
                ServiceConfiguration m_s_scObject  = (this.Depth > 1) ? m_s_scTable.CreateInstance() : null;
                Template             m_s_tObject   = (this.Depth > 1) ? m_s_tTable.CreateInstance() : null;
                Service              m_sObject     = (this.Depth > 0) ? m_sTable.CreateInstance(m_s_aObject, m_s_pObject, m_s_mObject, m_s_stObject, m_s_ustObject, m_s_cObject, m_s_lObject, m_s_scObject, m_s_tObject) : null;
                User           m_c_uObject         = (this.Depth > 1) ? m_c_uTable.CreateInstance() : null;
                Service        m_c_sObject         = (this.Depth > 1) ? m_c_sTable.CreateInstance() : null;
                Country        m_c_cObject         = (this.Depth > 1) ? m_c_cTable.CreateInstance() : null;
                Language       m_c_lObject         = (this.Depth > 1) ? m_c_lTable.CreateInstance() : null;
                MobileOperator m_c_moObject        = (this.Depth > 1) ? m_c_moTable.CreateInstance() : null;
                Customer       m_cObject           = (this.Depth > 0) ? m_cTable.CreateInstance(m_c_uObject, m_c_sObject, m_c_cObject, m_c_lObject, m_c_moObject) : null;
                Country        m_mo_cObject        = (this.Depth > 1) ? m_mo_cTable.CreateInstance() : null;
                MobileOperator m_moObject          = (this.Depth > 0) ? m_moTable.CreateInstance(m_mo_cObject) : null;
                Message        mObject             = mTable.CreateInstance(m_sObject, m_cObject, m_moObject);
                sqlReader.Close();

                return(mObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("m", "loadinternal", "exception"), "Message could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Message", "Exception while loading Message object from database. See inner exception for details.", ex);
            }
        }