-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
110 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="edit skill" type="DotNetProject" factoryName=".NET Project" folderName="edit"> | ||
<option name="EXE_PATH" value="$PROJECT_DIR$/Resumer/bin/Debug/net8.0/Resumer.exe" /> | ||
<option name="PROGRAM_PARAMETERS" value="edit skill" /> | ||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Resumer/bin/Debug/net8.0" /> | ||
<option name="PASS_PARENT_ENVS" value="1" /> | ||
<option name="USE_EXTERNAL_CONSOLE" value="0" /> | ||
<option name="USE_MONO" value="0" /> | ||
<option name="RUNTIME_ARGUMENTS" value="" /> | ||
<option name="PROJECT_PATH" value="$PROJECT_DIR$/Resumer/Resumer.csproj" /> | ||
<option name="PROJECT_EXE_PATH_TRACKING" value="1" /> | ||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" /> | ||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" /> | ||
<option name="PROJECT_KIND" value="DotNetCore" /> | ||
<option name="PROJECT_TFM" value="net8.0" /> | ||
<method v="2"> | ||
<option name="Build" /> | ||
</method> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Resumer.models; | ||
using Spectre.Console; | ||
using Spectre.Console.Cli; | ||
using Command = Spectre.Console.Cli.Command; | ||
|
||
namespace Resumer.cli.commands.edit; | ||
|
||
public class EditSkillCommand: Command | ||
{ | ||
public override int Execute(CommandContext context) | ||
{ | ||
var db = new ResumeContext(); | ||
|
||
var skill = AnsiConsole.Prompt(new SelectionPrompt<Skill>() | ||
.Title("Select skill to edit") | ||
.AddChoices(db.Skills.OrderBy(s => s.Name)) | ||
.WrapAround() | ||
.PageSize(10) | ||
); | ||
db.Skills.Update(skill); | ||
AnsiConsole.WriteLine($"Editing: {skill}"); | ||
|
||
var name = AnsiConsole.Prompt(new TextPrompt<string>("Name:").DefaultValue(skill.Name)); | ||
var type = AnsiConsole.Prompt(new TextPrompt<SkillType>("Type (hard/soft):").DefaultValue(skill.Type)); | ||
|
||
|
||
// because skill.name is the PK and it's not a [foreign key assoc.](https://stackoverflow.com/questions/5281974/code-first-independent-associations-vs-foreign-key-associations/5282275#5282275) | ||
// tl;dr remove and insert to update 🙄 | ||
if(!skill.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)) | ||
{ | ||
db.Skills.Remove(skill); | ||
db.Skills.Add(new Skill(name, type)); | ||
} | ||
else | ||
skill.Type = type; | ||
|
||
db.SaveChanges(); | ||
|
||
return CommandOutput.Success("Skill updated successfully"); | ||
} | ||
} |