public async Task <UProject_ProjectSummaryList> GetProjectSummariesAsync(string userId, int?skip, int?take) { using var log = BeginFunction(nameof(ProjectUserService), nameof(GetProjectSummariesAsync), userId, skip, take); try { await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); var ownerReference = CreateOwnerReference.FromUserId(userId); var ownerId = await ProjectMicroService.AllocateOwnerAsync(ownerReference).ConfigureAwait(false); var entries = await ProjectMicroService.GetProjectsAsync(ownerId, skip, take).ConfigureAwait(false); var hasDeletedProjects = await ProjectMicroService.HasDeletedProjectsAsync(ownerId).ConfigureAwait(false); var summaries = Create.UProject_ProjectSummaries(entries); var result = new UProject_ProjectSummaryList() { ProjectSummaries = summaries, HasDeletedProjects = hasDeletedProjects }; log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }
public async Task <string> UndeleteDesignAsync(string userId) { using var log = BeginFunction(nameof(DesignUserService), nameof(UndeleteDesignAsync), userId, userId); try { await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); var ownerReference = CreateOwnerReference.FromUserId(userId); var ownerId = await DesignMicroService.AllocateOwnerAsync(ownerReference).ConfigureAwait(false); var id = await DesignMicroService.UndeleteDesignAsync(ownerId).ConfigureAwait(false); if (id.HasValue) { var result = id.Value.ToString(); log.Result(result); return(result); } log.Result(null); return(null); } catch (Exception ex) { log.Exception(ex); throw; } }
public async Task <string> CreateDesignAsync(string userId, string designName) { using var log = BeginFunction(nameof(DesignUserService), nameof(CreateDesignAsync), userId, designName); try { await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); var fabricStyles = new FabricStyleList { new FabricStyle(FabricStyle.UNKNOWN_SKU, Color.Red), new FabricStyle(FabricStyle.UNKNOWN_SKU, Color.Green), new FabricStyle(FabricStyle.UNKNOWN_SKU, Color.Blue) }; var provider = new BuiltInQuiltLayoutComponenProvider(); var entry = provider.GetComponent(LayoutComponent.TypeName, Constants.DefaultComponentCategory, BuiltInQuiltLayoutComponenProvider.ComponentName_Checkerboard); var design = new Design.Core.Design() { Width = new Dimension(48, DimensionUnits.Inch), Height = new Dimension(48, DimensionUnits.Inch) }; var component = LayoutComponent.Create(entry.Category, entry.Name, fabricStyles, 3, 3, entry.BlockCount); design.LayoutComponent = component; var ownerReference = CreateOwnerReference.FromUserId(userId); var ownerId = await DesignMicroService.AllocateOwnerAsync(ownerReference).ConfigureAwait(false); var mDesignSpecification = BusinessDataFactory.Create_MDesign_DesignSpecification(design); var id = await DesignMicroService.CreateDesignAsync(ownerId, designName, mDesignSpecification, GetUtcNow()).ConfigureAwait(false); var result = id.ToString(); log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }
public async Task <Guid?> UndeleteProjectAsync(string userId) { using var log = BeginFunction(nameof(ProjectUserService), nameof(UndeleteProjectAsync), userId); try { await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); var ownerReference = CreateOwnerReference.FromUserId(userId); var ownerId = await ProjectMicroService.AllocateOwnerAsync(ownerReference).ConfigureAwait(false); var result = await ProjectMicroService.UndeleteProjectAsync(ownerId, GetUtcNow()).ConfigureAwait(false); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }
public async Task <Guid> SaveDesignAsync(string userId, XDesign_Design design) { using var log = BeginFunction(nameof(DesignAjaxService), nameof(SaveDesignAsync), userId, design); try { var ownerReference = CreateOwnerReference.FromUserId(userId); var ownerId = await DesignMicroService.AllocateOwnerAsync(ownerReference).ConfigureAwait(false); var result = string.IsNullOrEmpty(design.designId) ? await DesignMicroService.CreateDesignAsync(ownerId, design.designName, BusinessDataFactory.Create_MDesign_DesignSpecification(design), GetUtcNow()).ConfigureAwait(false) : await DesignMicroService.UpdateDesignAsync(Guid.Parse(design.designId), BusinessDataFactory.Create_MDesign_DesignSpecification(design), GetUtcNow()).ConfigureAwait(false); log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }
public async Task <string> CreateProjectAsync(string userId, string projectType, string projectName, Guid designId) { using var log = BeginFunction(nameof(ProjectUserService), nameof(CreateProjectAsync), projectType, userId, projectName, designId); try { await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); string result; if (projectType == ProjectType_Kit) { var mDesign = await DesignMicroService.GetDesignAsync(designId).ConfigureAwait(false); var design = new Design.Core.Design(JToken.Parse(mDesign.DesignArtifactValue)); var projectData = ProjectLibraryKitUtility.CreateProjectSpecification(design); var ownerReference = CreateOwnerReference.FromUserId(userId); var ownerId = await ProjectMicroService.AllocateOwnerAsync(ownerReference).ConfigureAwait(false); var id = await ProjectMicroService.CreateProjectAsync(ownerId, projectName, ProjectTypeCodes.Kit, mDesign.DesignSnapshotId, projectData, GetUtcNow()).ConfigureAwait(false); result = id.ToString(); } else { throw new ArgumentException(string.Format("Unknown projectType {0}", projectType), nameof(projectType)); } log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }