示例#1
0
        public static DashboardTileApiModel FromDashboardTile(DashboardTile dashboardTile)
        {
            var model = new DashboardTileApiModel();

            model.DashboardTileId = dashboardTile.DashboardTileId;
            model.Name            = dashboardTile.Name;
            return(model);
        }
示例#2
0
 public static TModel FromDashboardTile <TModel>(DashboardTile dashboardTile) where
 TModel : DashboardTileApiModel, new() => new TModel
 {
     Id          = dashboardTile.Id,
     TenantId    = dashboardTile.TenantId,
     Name        = dashboardTile.Name,
     Width       = dashboardTile.Width,
     Height      = dashboardTile.Height,
     Top         = dashboardTile.Top,
     Left        = dashboardTile.Left,
     TileId      = dashboardTile.TileId,
     DashboardId = dashboardTile.DashboardId,
     Tile        = TileApiModel.FromTile(dashboardTile.Tile)
 };
        public static TModel FromDashboardTile <TModel>(DashboardTile dashboardTile) where
        TModel : DashboardTileApiModel, new()
        {
            var model = new TModel();

            model.Id          = dashboardTile.Id;
            model.TenantId    = dashboardTile.TenantId;
            model.Name        = dashboardTile.Name;
            model.DashboardId = dashboardTile.DashboardId;
            model.TileId      = dashboardTile.TileId;
            model.Top         = dashboardTile.Top;
            model.Left        = dashboardTile.Left;
            model.Width       = dashboardTile.Width;
            model.Height      = dashboardTile.Height;
            model.Tile        = TileApiModel.FromTile(dashboardTile.Tile);
            return(model);
        }
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var dashboardTile = await _context.DashboardTiles.FindAsync(request.DashboardTile.DashboardTileId);

                if (dashboardTile == null)
                {
                    _context.DashboardTiles.Add(dashboardTile = new DashboardTile());
                }

                dashboardTile.Name = request.DashboardTile.Name;

                await _context.SaveChangesAsync(cancellationToken, request.Username);

                return(new Response()
                {
                    DashboardTileId = dashboardTile.DashboardTileId
                });
            }
示例#5
0
            public async Task <Response> Handle(Request request)
            {
                var entity = await _context.DashboardTiles
                             .Include(x => x.Tenant)
                             .Include(x => x.Dashboard)
                             .Include(x => x.Tile)
                             .SingleOrDefaultAsync(x => x.Id == request.DashboardTile.Id && x.Tenant.UniqueId == request.TenantUniqueId);

                if (entity == null)
                {
                    var tenant = await _context.Tenants.SingleAsync(x => x.UniqueId == request.TenantUniqueId);

                    var dashboard = await _context.Dashboards.Include(x => x.DashboardTiles).SingleAsync(x => x.Id == request.DashboardTile.DashboardId);

                    var tile = await _context.Tiles.SingleAsync(x => x.Id == request.DashboardTile.TileId);

                    if (dashboard.DashboardTiles.SingleOrDefault(x => x.TileId == request.DashboardTile.TileId) != null)
                    {
                        throw new Exception("Tile Exists. Can not add duplicate");
                    }

                    _context.DashboardTiles.Add(entity = new DashboardTile()
                    {
                        TenantId = tenant.Id, Dashboard = dashboard, Tile = tile
                    });
                }

                entity.Name        = request.DashboardTile.Name;
                entity.DashboardId = request.DashboardTile.DashboardId;
                entity.TileId      = request.DashboardTile.TileId;
                entity.Top         = request.DashboardTile.Top;
                entity.Left        = request.DashboardTile.Left;
                entity.Width       = request.DashboardTile.Width;
                entity.Height      = request.DashboardTile.Height;
                await _context.SaveChangesAsync();

                _bus.Publish(new AddedOrUpdatedDashboardTileMessage(DashboardTileApiModel.FromDashboardTile(entity), request.CorrelationId, request.TenantUniqueId));

                return(new Response());
            }
示例#6
0
            public async Task <Response> Handle(Request request)
            {
                var entity = await _context.DashboardTiles
                             .Include(x => x.Tenant)
                             .Include(x => x.Dashboard)
                             .Include("Dashboard.DashboardTiles")
                             .SingleOrDefaultAsync(x => x.Id == request.DashboardTile.Id && x.Tenant.UniqueId == request.TenantUniqueId);

                if (entity == null)
                {
                    var tenant = await _context.Tenants.SingleAsync(x => x.UniqueId == request.TenantUniqueId);

                    var dashboard = _context.Dashboards
                                    .Include(x => x.DashboardTiles)
                                    .Single(x => x.Id == request.DashboardTile.DashboardId.Value &&
                                            x.Tenant.UniqueId == request.TenantUniqueId);

                    _context.DashboardTiles.Add(entity = new DashboardTile()
                    {
                        TenantId = tenant.Id
                    });

                    dashboard.DashboardTiles.Add(entity);
                }

                entity.TileId = request.DashboardTile.TileId;
                entity.Name   = request.DashboardTile.Name;
                entity.Top    = request.DashboardTile.Top;
                entity.Left   = request.DashboardTile.Left;
                entity.Width  = request.DashboardTile.Width;
                entity.Height = request.DashboardTile.Height;

                await _context.SaveChangesAsync(request.Username);

                return(new Response());
            }
示例#7
0
 public static DashboardTileApiModel FromDashboardTile(DashboardTile dashboardTile)
 => FromDashboardTile <DashboardTileApiModel>(dashboardTile);