public JsonResult Create(DashboardModel model) { var uow = Helper.GetUnitOfWorkByCurrentUser(); var name = model.Name.Trim(); var dashboard = new Dashboard() { Name = name, FriendlyUrl = Helper.CreateFriendlyURL(name) }; var dashboardExists = uow.Dashboards.Get(f => f.FriendlyUrl == dashboard.FriendlyUrl).FirstOrDefault(); if (dashboardExists != null) throw new Exception("Já existe um dashboard cadastrado com esse mesmo nome, tente outro."); uow.Dashboards.Insert(dashboard); return Json(new { Success = true }); }
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; }