Example #1
0
 public static DestinationFolderEntity ToEntity(this DestinationFolderCreateData createData)
 => new DestinationFolderEntity
 {
     Id           = Guid.NewGuid(),
     Path         = createData.Path,
     CollectionId = createData.CollectionId,
     WithoutHashErrorSubfolder    = createData.WithoutHashErrorSubfolder,
     ShouldCreateSubfoldersByHash = createData.ShouldCreateSubfoldersByHash,
     HashErrorSubfolder           = createData.HashErrorSubfolder,
     ShouldRenameByHash           = createData.ShouldRenameByHash,
     FormatErrorSubfolder         = createData.FormatErrorSubfolder
 };
Example #2
0
    public static DestinationFolderEntity ToEntity(
        this DestinationFolderCreateData createData,
        DestinationFolderEntity updateCurrent)
    {
        updateCurrent.Path = createData.Path;
        updateCurrent.WithoutHashErrorSubfolder    = createData.WithoutHashErrorSubfolder;
        updateCurrent.ShouldCreateSubfoldersByHash = createData.ShouldCreateSubfoldersByHash;
        updateCurrent.HashErrorSubfolder           = createData.HashErrorSubfolder;
        updateCurrent.ShouldRenameByHash           = createData.ShouldRenameByHash;
        updateCurrent.FormatErrorSubfolder         = createData.FormatErrorSubfolder;

        return(updateCurrent);
    }
Example #3
0
    public async Task <CustomDestinationFolder> AddOrReplace(DestinationFolderCreateData createData)
    {
        var currentDestFolderEntity = await _roomDbContext
                                      .DestinationFolders
                                      .FirstOrDefaultAsync(x => x.CollectionId == createData.CollectionId);

        DestinationFolderEntity entity;

        if (currentDestFolderEntity != null)
        {
            entity = createData.ToEntity(currentDestFolderEntity);
        }
        else
        {
            entity = createData.ToEntity();
            await _roomDbContext.AddAsync(entity);
        }

        await _roomDbContext.SaveChangesAsync();

        return(_mapper.Map <CustomDestinationFolder>(entity));
    }