-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWorksheetInstanceAppService.cs
More file actions
33 lines (27 loc) · 1.67 KB
/
WorksheetInstanceAppService.cs
File metadata and controls
33 lines (27 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Threading.Tasks;
using System;
using Microsoft.AspNetCore.Authorization;
using Unity.Flex.Domain.WorksheetInstances;
using Unity.Flex.Domain.Services;
namespace Unity.Flex.WorksheetInstances
{
[Authorize]
public class WorksheetInstanceAppService(IWorksheetInstanceRepository worksheetInstanceRepository, WorksheetsManager worksheetsManager) : FlexAppService, IWorksheetInstanceAppService
{
public virtual async Task<WorksheetInstanceDto> GetByCorrelationAnchorAsync(Guid correlationId, string correlationProvider, Guid worksheetId, string uiAnchor)
{
return ObjectMapper.Map<WorksheetInstance?, WorksheetInstanceDto>(await worksheetInstanceRepository.GetByCorrelationAnchorWorksheetAsync(correlationId, correlationProvider, worksheetId, uiAnchor, true));
}
public virtual async Task<WorksheetInstanceDto> CreateAsync(CreateWorksheetInstanceDto dto)
{
var newWorksheet = new WorksheetInstance(Guid.NewGuid(), dto.WorksheetId, dto.CorrelationId, dto.CorrelationProvider, dto.SheetCorrelationId, dto.SheetCorrelationProvider, dto.CorrelationAnchor, dto.ReportData);
if (!string.IsNullOrEmpty(dto.CurrentValue)) { newWorksheet.SetValue(dto.CurrentValue); }
var dbWorksheet = await worksheetInstanceRepository.InsertAsync(newWorksheet);
return ObjectMapper.Map<WorksheetInstance, WorksheetInstanceDto>(dbWorksheet);
}
public virtual async Task UpdateAsync(PersistWorksheetIntanceValuesDto dto)
{
await worksheetsManager.PersistWorksheetData(ObjectMapper.Map<PersistWorksheetIntanceValuesDto, PersistWorksheetIntanceValuesEto>(dto));
}
}
}