Example #1
0
        public static DataTable DoesExist(ThemeDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new ThemeDataModel();

            doesExistRequest.Name = data.Name;
            return(Search(doesExistRequest, requestProfile));
        }
Example #2
0
        public void LoadData(int themeId, bool showId)
        {
            Clear();

            var data = new ThemeDataModel();

            data.ThemeId = themeId;

            var items = Framework.Components.Core.ThemeDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            SetData(item);

            if (!showId)
            {
                SystemKeyId = item.ThemeId;
                // oHistoryList.Setup(PrimaryEntity, ThemeId, PrimaryEntityKey);
            }
            else
            {
                CoreSystemKey.Text = String.Empty;
            }
        }
Example #3
0
        protected override void ShowData(int ThemeId)
        {
            oDetailButtonPanel.SetId = SetId;
            var data = new ThemeDataModel();

            data.ThemeId = ThemeId;

            var items = Framework.Components.Core.ThemeDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count == 1)
            {
                var item = items[0];

                lblThemeId.Text     = item.ThemeId.ToString();
                lblName.Text        = item.Name;
                lblDescription.Text = item.Description;
                lblSortOrder.Text   = item.SortOrder.ToString();
                //lblIsAllTab.Text = item.IsAllTab.ToString();

                oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);

                oHistoryList.Setup(PrimaryEntity, ThemeId, "Theme");
            }
            else
            {
                Clear();
            }
        }
Example #4
0
        public async Task SaveThemeData(ThemeDataModel model, bool isActive)
        {
            if (!GetThemes().Contains(model.Theme))
            {
                var msg = $"Theme \"{model.Theme}\" does not exist";
                _logger.LogError(msg);
                throw new ApplicationException(msg);
            }
            try
            {
                var tmpObj = JContainer.Parse(model.Data);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw new ApplicationException(ex.Message);
            }
            string jsonFile = $"{AppSettings.WebRootPath}{_separator}themes{_separator}{model.Theme}{_separator}assets{_separator}{Constants.ThemeDataFile}";
            if (File.Exists(jsonFile))
            {
                File.Delete(jsonFile);
                File.WriteAllText(jsonFile, model.Data);
            }
            if (isActive)
            {
                jsonFile = $"{AppSettings.WebRootPath}{_separator}themes{_separator}_active{_separator}assets{_separator}{Constants.ThemeDataFile}";
                if (File.Exists(jsonFile))
                {
                    File.Delete(jsonFile);
                    File.WriteAllText(jsonFile, model.Data);
                }
            }

            await Task.CompletedTask;
        }
Example #5
0
        public static int Create(ThemeDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("Theme.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Example #6
0
        public static string Save(ThemeDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

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

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

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

            return(sql);
        }
Example #7
0
        public override int?Save(string action)
        {
            var data = new ThemeDataModel();

            data.ThemeId     = SystemKeyId;
            data.Name        = Name;
            data.Description = Description;
            data.SortOrder   = SortOrder;
            //data.IsAllTab = IsAllTab;

            if (action == "Insert")
            {
                var dtTheme = Framework.Components.Core.ThemeDataManager.DoesExist(data, SessionVariables.RequestProfile);

                if (dtTheme.Rows.Count == 0)
                {
                    Framework.Components.Core.ThemeDataManager.Create(data, SessionVariables.RequestProfile);
                }
                else
                {
                    throw new Exception("Record with given ID already exists.");
                }
            }
            else
            {
                Framework.Components.Core.ThemeDataManager.Update(data, SessionVariables.RequestProfile);
            }

            return(data.ThemeId);
        }
Example #8
0
        protected override void Clear()
        {
            base.Clear();

            var data = new ThemeDataModel();

            SetData(data);
        }
Example #9
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var Themedata = new ThemeDataModel();

            Themedata.ThemeId = entityKey;
            var results = Framework.Components.Core.ThemeDataManager.Search(Themedata, SessionVariables.RequestProfile);

            return(results);
        }
Example #10
0
        public static DataSet GetChildren(ThemeDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.ThemeChildrenGet" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, ThemeDataModel.DataColumns.ThemeId);
            var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Example #11
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new ThemeDataModel();

            // copies properties from values dictionary object to data object
            PropertyMapper.CopyProperties(data, values);

            Framework.Components.Core.ThemeDataManager.Update(data, SessionVariables.RequestProfile);
            base.Update(values);
        }
Example #12
0
        public static bool DoesExist(ThemeDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new ThemeDataModel();

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

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

            return(list.Count > 0);
        }
Example #13
0
        public static DataTable ListOfParentThemeOnly(ThemeDataModel data, RequestProfile requestProfile)
        {
            // formulate SQL
            var sql = "EXEC dbo.ThemesListOfParentMenuOnly " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);

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

            return(oDT.DBTable);
        }
Example #14
0
        public async Task SaveThemeData(ThemeDataModel model)
        {
            string jsonFile = $"{AppSettings.WebRootPath}{_separator}themes{_separator}{model.Theme}{_separator}assets{_separator}{Constants.ThemeDataFile}";

            if (File.Exists(jsonFile))
            {
                File.Delete(jsonFile);
                File.WriteAllText(jsonFile, model.Data);
            }
            await Task.CompletedTask;
        }
Example #15
0
        public async Task <IActionResult> SaveThemeData(ThemeDataModel model)
        {
            try
            {
                await _store.SaveThemeData(model);

                return(Ok("Created"));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "File save error"));
            }
        }
Example #16
0
        public static void Delete(ThemeDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.ThemeDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
        public async Task <IActionResult> SaveThemeData(ThemeDataModel model)
        {
            try
            {
                var settings = await _data.CustomFields.GetBlogSettings();

                var isActive = settings.Theme == model.Theme;

                await _store.SaveThemeData(model, isActive);

                return(Ok("Created"));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "File save error"));
            }
        }
Example #18
0
        public static bool IsDeletable(ThemeDataModel 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);
        }
Example #19
0
        public async Task <IActionResult> SaveThemeData(ThemeDataModel model)
        {
            try
            {
                var settings = await _data.CustomFields.GetBlogSettings();

                var isActive = settings.Theme == model.Theme;

                await _store.SaveThemeData(model, isActive);

                Log.Information("{prefix}: Created new theme type: {theme}", FilterPrefixes.THEME, settings.Theme);
                Log.Debug("{prefix}: Saved data for theme type: {theme}", FilterPrefixes.THEME, settings.Theme);
                return(Ok("Created"));
            }
            catch (Exception)
            {
                Log.Error("{prefix}: Error creating new theme", FilterPrefixes.THEME);
                return(StatusCode(StatusCodes.Status500InternalServerError, "File save error"));
            }
        }
Example #20
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var notDeletableIds = new List <int>();
                var deleteIndexList = DeleteIds.Split(',');

                foreach (string index in deleteIndexList)
                {
                    var data = new ThemeDataModel();
                    data.ThemeId = int.Parse(index);
                    Framework.Components.Core.ThemeDataManager.Delete(data, SessionVariables.RequestProfile);
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Example #21
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new ThemeDataModel();

            UpdatedData = Framework.Components.Core.ThemeDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.ThemeId =
                    Convert.ToInt32(SelectedData.Rows[i][ThemeDataModel.DataColumns.ThemeId].ToString());

                data.SortOrder =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder))
                                        : int.Parse(SelectedData.Rows[i][StandardDataModel.StandardDataColumns.SortOrder].ToString());

                data.Name =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Name))
                                        ? CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Name)
                                        : SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Name].ToString();

                data.Description =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description))
                                        ? CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description)
                                        : SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Description].ToString();

                Framework.Components.Core.ThemeDataManager.Update(data, SessionVariables.RequestProfile);
                data         = new ThemeDataModel();
                data.ThemeId =
                    Convert.ToInt32(SelectedData.Rows[i][ThemeDataModel.DataColumns.ThemeId].ToString());
                var dt = Framework.Components.Core.ThemeDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Example #22
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows = new DataTable();
                var Themedata    = new ThemeDataModel();

                selectedrows = ThemeDataManager.GetDetails(Themedata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        Themedata.ThemeId = entityKey;
                        var result = ThemeDataManager.GetDetails(Themedata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    Themedata.ThemeId = SetId;
                    var result = ThemeDataManager.GetDetails(Themedata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(null);
        }
Example #23
0
        public static List <ThemeDataModel> GetEntityDetails(ThemeDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.ThemeSearch ";

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

            List <ThemeDataModel> result;

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

            return(result);
        }
Example #24
0
        public static string ToSQLParameter(ThemeDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

            return(returnValue);
        }
Example #25
0
        public static ThemeDataModel GetDetails(ThemeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Example #26
0
        public static void Update(ThemeDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("Theme.Update", sql, DataStoreKey);
        }
Example #27
0
        public static DataTable Search(ThemeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Example #28
0
        public void SetData(ThemeDataModel data)
        {
            SystemKeyId = data.ThemeId;

            base.SetData(data);
        }