Exemplo n.º 1
0
        public async Task <OkObjectResult> GetPackage(string name)
        {
            var entity = await _services.GetPackageByName(name);

            var result = PackageViewModel.FromEntity(entity);

            if (result.ProjectBlockId != null)
            {
                var layoutBlock = _projecst.GetParentOfProjectBlock(result.ProjectBlockId ?? 0);
                result.Layout = ProjectBlockViewModelExtension.FromEnitity(layoutBlock);

                var perspective = _projecst.GetProjectBlock(result.ProjectBlockId ?? 0);
                result.Perspective = ProjectBlockViewModelExtension.FromEnitity(perspective);
            }

            return(Ok(result));
        }
        public OkObjectResult getRoom(long id)
        {
            var roomLayout = _projects.GetProjectBlock(id);
            var result     = ProjectBlockViewModelExtension.FromEnitity(roomLayout);

            if (roomLayout.ParentId != null)
            {
                var parent = _projects.GetParentOfProjectBlock(roomLayout.Id);
                if (parent != null)
                {
                    result.Project = new ProjectViewModel
                    {
                        Id   = parent.Project.Id,
                        Name = parent.Project.Name
                    }
                }
                ;
            }
            return(Ok(result));
        }
    }
Exemplo n.º 3
0
        public static ProjectBlock FromViewModel(ProjectBlockViewModel viewModel)
        {
            var files = new List <ProjectBlockFile>();

            if (viewModel.LayoutImage != null)
            {
                files.Add(ProjectBlockViewModelExtension.GetFileViewModel(viewModel));
            }

            if (viewModel.LayoutPoints != null)
            {
                files.AddRange(
                    viewModel.LayoutPoints.Where(o => o.Image != null).Select(o =>
                {
                    return(new ProjectBlockFile
                    {
                        EntityId = viewModel.Id,
                        FileEntityId = o.Image.FileId,
                        UsingType = 1,
                        JsonData = (o != null) ? Newtonsoft.Json.JsonConvert.SerializeObject(o) : default
                    });
                }));