Persist structured CV section data
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using JobTrackerApi.Services;
|
||||
using JobTrackerApi.Models;
|
||||
@@ -86,6 +87,8 @@ public sealed class ProfileCvController : ControllerBase
|
||||
}
|
||||
|
||||
user.ProfileCvText = text;
|
||||
user.ProfileCvStructureJson = JsonSerializer.Serialize(
|
||||
ParseSections(text).Select(section => new ParsedCvSectionDto(section.Name, section.Content, CountWords(section.Content))).ToList());
|
||||
var result = await _users.UpdateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
@@ -114,6 +117,8 @@ public sealed class ProfileCvController : ControllerBase
|
||||
}
|
||||
|
||||
user.ProfileCvText = rebuilt.Trim();
|
||||
user.ProfileCvStructureJson = JsonSerializer.Serialize(
|
||||
ParseSections(user.ProfileCvText).Select(section => new ParsedCvSectionDto(section.Name, section.Content, CountWords(section.Content))).ToList());
|
||||
var result = await _users.UpdateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
@@ -161,6 +166,13 @@ public sealed class ProfileCvController : ControllerBase
|
||||
.Select(section => new ParsedCvSectionDto(section.Name, section.Content, CountWords(section.Content)))
|
||||
.ToList();
|
||||
|
||||
user.ProfileCvStructureJson = JsonSerializer.Serialize(sections);
|
||||
var update = await _users.UpdateAsync(user);
|
||||
if (!update.Succeeded)
|
||||
{
|
||||
return BadRequest(string.Join("; ", update.Errors.Select(e => e.Description)));
|
||||
}
|
||||
|
||||
return Ok(new { sections, totalWords = CountWords(source) });
|
||||
}
|
||||
|
||||
@@ -183,6 +195,8 @@ public sealed class ProfileCvController : ControllerBase
|
||||
}
|
||||
|
||||
user.ProfileCvText = improved.Trim();
|
||||
user.ProfileCvStructureJson = JsonSerializer.Serialize(
|
||||
ParseSections(user.ProfileCvText).Select(section => new ParsedCvSectionDto(section.Name, section.Content, CountWords(section.Content))).ToList());
|
||||
var result = await _users.UpdateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user