Esempio n. 1
0
        //public void ReorderPanels(bool addAfterIfOccurConflict = false)
        //{
        //    List<Panel> panels;
        //    // add after  : order by panelOrder and if has conflict, set the oldest first.
        //    if (addAfterIfOccurConflict)
        //        panels = this.Panels.OrderBy(one => one.PanelOrder).ThenBy(two => two.LastUpdateDate).ToList();
        //    // add before: order by panelOrder and if has conflict, set the newest first.
        //    else
        //        panels = this.Panels.OrderBy(one => one.PanelOrder).ThenByDescending(two => two.LastUpdateDate).ToList();
        //    var i = 1;
        //    foreach (var panel in panels)
        //        panel.PanelOrder = i++;
        //}
        public void ReorderPanel(Panel panelToOrder = null, int newOrder = 0)
        {
            var panels = this.Panels.OrderBy(one => one.PanelOrder).ToList();

            if (panelToOrder != null)
            {
                panels.Remove(panelToOrder);

                if (newOrder <= panels.Count)
                    panels.Insert(newOrder - 1, panelToOrder);
                else
                    panels.Add(panelToOrder);
            }

            var i = 1;
            foreach (var panel in panels)
                panel.PanelOrder = i++;
        }
        private PanelModel ConvertObjectDomainToModel(Panel panel, Dashboard dashboard)
        {
            var model = new PanelModel();

            if (panel != null)
            {
                model.Title = panel.Title;
                model.Id = panel.Id;
                model.Dashboard = dashboard;
                model.PanelOrder = panel.PanelOrder;
                model.PanelWidth = panel.PanelWidth;
                model.PanelComponents = panel.PanelComponents;
                model.DisplayY = panel.DisplayY;

                model.GroupBy = panel.GroupBy;
                model.GroupByOrderBy = panel.GroupByOrderBy;
                model.GroupByOrderByClassification = panel.GroupByOrderByClassification;
                model.GroupByOrderByGroup = panel.GroupByOrderByGroup;
                model.GroupByOrderByGroupClassification = panel.GroupByOrderByGroupClassification;

                model.GroupBy2 = panel.GroupBy2;
                model.GroupByOrderBy2 = panel.GroupByOrderBy2;
                model.GroupByOrderByClassification2 = panel.GroupByOrderByClassification2;
                model.GroupByOrderByGroup2 = panel.GroupByOrderByGroup2;
                model.GroupByOrderByGroupClassification2 = panel.GroupByOrderByGroupClassification2;

                model.GroupBy3 = panel.GroupBy3;
                model.GroupByOrderBy3 = panel.GroupByOrderBy3;
                model.GroupByOrderByClassification3 = panel.GroupByOrderByClassification3;
                model.GroupByOrderByGroup3 = panel.GroupByOrderByGroup3;
                model.GroupByOrderByGroupClassification3 = panel.GroupByOrderByGroupClassification3;

                model.OrderBy = panel.Filter.OrderBy;
                model.OrderByClassification = panel.Filter.OrderByClassification;
                model.FilterTransactionType = panel.Filter.TransactionType;
                model.FilterDateStart = panel.Filter.DateStart;
                model.FilterDateEnd = panel.Filter.DateEnd;
                model.FilterValueStart = panel.Filter.ValueStart;
                model.FilterValueEnd = panel.Filter.ValueEnd;
                model.ViewName = panel.ViewName;

                model.Panel = panel;

                if (panel.Filter.Categories != null)
                    model.FilterCategories = string.Join(",", panel.Filter.Categories);

                if (panel.Filter.SubCategories != null)
                    model.FilterSubCategories = string.Join(",", panel.Filter.SubCategories);

                if (panel.Filter.Names != null)
                    model.FilterTransactionNames = string.Join(",", panel.Filter.Names);
            }

            return model;
        }
        private Panel ConvertModelToObjectDomain(PanelModel model)
        {
            var panel = new Panel();
            panel.Title = model.Title;
            panel.PanelOrder = model.PanelOrder;
            panel.PanelWidth = model.PanelWidth;
            panel.PanelComponents = model.PanelComponents;
            panel.DisplayY = model.DisplayY;

            panel.GroupBy = model.GroupBy;
            panel.GroupByOrderBy = model.GroupByOrderBy;
            panel.GroupByOrderByClassification = model.GroupByOrderByClassification;
            panel.GroupByOrderByGroup = model.GroupByOrderByGroup;
            panel.GroupByOrderByGroupClassification = model.GroupByOrderByGroupClassification;

            panel.GroupBy2 = model.GroupBy2;
            panel.GroupByOrderBy2 = model.GroupByOrderBy2;
            panel.GroupByOrderByClassification2 = model.GroupByOrderByClassification2;
            panel.GroupByOrderByGroup2 = model.GroupByOrderByGroup2;
            panel.GroupByOrderByGroupClassification2 = model.GroupByOrderByGroupClassification2;

            panel.GroupBy3 = model.GroupBy3;
            panel.GroupByOrderBy3 = model.GroupByOrderBy3;
            panel.GroupByOrderByClassification3 = model.GroupByOrderByClassification3;
            panel.GroupByOrderByGroup3 = model.GroupByOrderByGroup3;
            panel.GroupByOrderByGroupClassification3 = model.GroupByOrderByGroupClassification3;

            //panel.OrderBy = model.OrderBy;
            //panel.OrderByClassification = model.OrderByClassification;
            panel.Filter = new TransactionFilter();
            panel.Filter.TransactionType = model.FilterTransactionType;
            panel.Filter.DateStart = model.FilterDateStart;
            panel.Filter.DateEnd = model.FilterDateEnd;
            panel.Filter.ValueStart = model.FilterValueStart;
            panel.Filter.ValueEnd = model.FilterValueEnd;
            panel.ViewName = model.ViewName;

            // depois tenho que apagar o orderby e orderbyclassification
            panel.Filter.OrderBy = model.OrderBy;
            panel.Filter.OrderByClassification = model.OrderByClassification;

            if (!string.IsNullOrWhiteSpace(model.FilterCategories))
            {
                panel.Filter.Categories = new List<string>();
                panel.Filter.Categories = model.FilterCategories.Split(',').Select(s => s.Trim()).ToList();
            }

            if (!string.IsNullOrWhiteSpace(model.FilterSubCategories))
            {
                panel.Filter.SubCategories = new List<string>();
                panel.Filter.SubCategories = model.FilterSubCategories.Split(',').Select(s => s.Trim()).ToList();
            }

            if (!string.IsNullOrWhiteSpace(model.FilterTransactionNames))
            {
                panel.Filter.Names = new List<string>();
                panel.Filter.Names = model.FilterTransactionNames.Split(',').Select(s => s.Trim()).ToList();
            }

            return panel;
        }