Esempio n. 1
0
        public static int Create(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("UserPreferenceDataType.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Esempio n. 2
0
        public static string Save(UserPreferenceDataTypeDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

            switch (action)
            {
            case "Create":
                sql += "dbo.UserPreferenceDataTypeInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.UserPreferenceDataTypeUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, UserPreferenceDataTypeDataModel.DataColumns.UserPreferenceDataTypeId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);

            return(sql);
        }
Esempio n. 3
0
        public static void Sync(int newApplicationId, int oldApplicationId, RequestProfile requestProfile)
        {
            // get all records for old Application Id
            var sql = "EXEC dbo.UserPreferenceDataTypeSearch " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, oldApplicationId);

            var oDT = new DBDataTable("UserPreferenceDataType.Search", sql, DataStoreKey);

            // formaulate a new request Profile which will have new Applicationid
            var newRequestProfile = new RequestProfile();

            newRequestProfile.ApplicationId = newApplicationId;
            newRequestProfile.AuditId       = requestProfile.AuditId;

            foreach (DataRow dr in oDT.DBTable.Rows)
            {
                var data = new UserPreferenceDataTypeDataModel();
                data.ApplicationId = newApplicationId;
                data.Name          = dr[StandardDataModel.StandardDataColumns.Name].ToString();

                // check for existing record in new Application Id
                if (!DoesExist(data, newRequestProfile))
                {
                    data.Description = dr[StandardDataModel.StandardDataColumns.Description].ToString();
                    data.SortOrder   = Convert.ToInt32(dr[StandardDataModel.StandardDataColumns.SortOrder]);

                    //create in new application id
                    Create(data, newRequestProfile);
                }
            }
        }
Esempio n. 4
0
        public static DataSet GetChildren(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.UserPreferenceDataTypeChildrenGet" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, UserPreferenceDataTypeDataModel.DataColumns.UserPreferenceDataTypeId);
            var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Esempio n. 5
0
        public static bool DoesExist(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new UserPreferenceDataTypeDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Esempio n. 6
0
        public static void Delete(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.UserPreferenceDataTypeDelete ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                , UserPreferenceDataTypeId = data.UserPreferenceDataTypeId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Esempio n. 7
0
        public static void Sync(int newApplicationId, int oldApplicationId, RequestProfile requestProfile)
        {
            // get all records for old Application Id
            var sql = "EXEC dbo.UserPreferenceKeySearch " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, oldApplicationId);

            var oDT = new DBDataTable("UserPreferenceKey.Search", sql, DataStoreKey);


            // formaulate a new request Profile which will have new Applicationid
            var newRequestProfile = new RequestProfile();

            newRequestProfile.ApplicationId = newApplicationId;
            newRequestProfile.AuditId       = requestProfile.AuditId;

            var dataTypedata = new UserPreferenceDataTypeDataModel();
            var dataTypeList = UserPreferenceDataTypeDataManager.GetEntityDetails(dataTypedata, newRequestProfile);

            foreach (DataRow dr in oDT.DBTable.Rows)
            {
                var data = new UserPreferenceKeyDataModel();
                data.ApplicationId = newApplicationId;
                data.Name          = dr[StandardDataModel.StandardDataColumns.Name].ToString();

                // check for existing record in new Application Id
                if (!DoesExist(data, newRequestProfile))
                {
                    var dataType = dr[UserPreferenceKeyDataModel.DataColumns.DataType].ToString();

                    //get new fc mode id based on fc mode name
                    var newDataTypeId = dataTypeList.Find(x => x.Name == dataType).UserPreferenceDataTypeId;

                    data.Description = dr[StandardDataModel.StandardDataColumns.Description].ToString();
                    data.Value       = dr[UserPreferenceKeyDataModel.DataColumns.Value].ToString();
                    if (string.IsNullOrEmpty(data.Value))
                    {
                        data.Value = " ";
                    }
                    data.DataTypeId = newDataTypeId;
                    data.SortOrder  = Convert.ToInt32(dr[StandardDataModel.StandardDataColumns.SortOrder]);

                    //create in new application id
                    Create(data, newRequestProfile);
                }
            }
        }
Esempio n. 8
0
        public static bool IsDeletable(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var isDeletable = true;
            var ds          = GetChildren(data, requestProfile);

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.Rows.Count > 0)
                    {
                        isDeletable = false;
                        break;
                    }
                }
            }
            return(isDeletable);
        }
Esempio n. 9
0
        public static List <UserPreferenceDataTypeDataModel> GetEntityDetails(UserPreferenceDataTypeDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.UserPreferenceDataTypeSearch ";

            var parameters =
                new
            {
                AuditId                    = requestProfile.AuditId
                , ApplicationId            = requestProfile.ApplicationId
                , ApplicationMode          = requestProfile.ApplicationModeId
                , ReturnAuditInfo          = returnAuditInfo
                , UserPreferenceDataTypeId = dataQuery.UserPreferenceDataTypeId
                , Name = dataQuery.Name
            };

            List <UserPreferenceDataTypeDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <UserPreferenceDataTypeDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Esempio n. 10
0
        public static string ToSQLParameter(UserPreferenceDataTypeDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case UserPreferenceDataTypeDataModel.DataColumns.UserPreferenceDataTypeId:
                if (data.UserPreferenceDataTypeId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, UserPreferenceDataTypeDataModel.DataColumns.UserPreferenceDataTypeId, data.UserPreferenceDataTypeId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, UserPreferenceDataTypeDataModel.DataColumns.UserPreferenceDataTypeId);
                }
                break;

            default:
                returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Esempio n. 11
0
        public static DataTable Search(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Esempio n. 12
0
        public static void Update(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("UserPreferenceDataType.Update", sql, DataStoreKey);
        }
Esempio n. 13
0
        public static UserPreferenceDataTypeDataModel GetDetails(UserPreferenceDataTypeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }