From 6d3ccf22875fcad6423d9593d87bb1a54ba2fe79 Mon Sep 17 00:00:00 2001 From: DotNetKiwi Date: Mon, 11 Sep 2017 13:36:45 +1200 Subject: [PATCH 1/2] Completed application and unit tests Completed application and unit tests --- .gitattributes | 63 ++++ .gitignore | 242 +++++++++++++ GeekHunter.sqlite | Bin 16384 -> 20480 bytes GeekHunter/GeekHunter.sln | 34 ++ GeekHunter/GeekHunter/App.config | 6 + GeekHunter/GeekHunter/Candidate.cs | 20 ++ GeekHunter/GeekHunter/DataService.cs | 43 +++ GeekHunter/GeekHunter/GeekHunter.csproj | 73 ++++ GeekHunter/GeekHunter/Program.cs | 39 +++ .../GeekHunter/Properties/AssemblyInfo.cs | 38 ++ GeekHunter/GeekHunter/SQLiteProcessor.cs | 116 +++++++ GeekHunter/GeekHunter/Skill.cs | 16 + GeekHunter/GeekHunterUI/App.config | 6 + GeekHunter/GeekHunterUI/App.xaml | 9 + GeekHunter/GeekHunterUI/App.xaml.cs | 17 + GeekHunter/GeekHunterUI/GeekHunterUI.csproj | 115 ++++++ GeekHunter/GeekHunterUI/MainViewModel.cs | 54 +++ GeekHunter/GeekHunterUI/MainWindow.xaml | 50 +++ GeekHunter/GeekHunterUI/MainWindow.xaml.cs | 53 +++ .../GeekHunterUI/Properties/AssemblyInfo.cs | 55 +++ .../Properties/Resources.Designer.cs | 63 ++++ .../GeekHunterUI/Properties/Resources.resx | 117 +++++++ .../Properties/Settings.Designer.cs | 26 ++ .../GeekHunterUI/Properties/Settings.settings | 7 + .../UnitTestGeekHunter/DataProviderTests.cs | 80 +++++ .../Properties/AssemblyInfo.cs | 36 ++ .../UnitTestGeekHunter.csproj | 100 ++++++ GeekHunter/UnitTestGeekHunter/packages.config | 5 + README.md | 38 +- sqlite3.exe | Bin 0 -> 750080 bytes sqliteadmin.zip | Bin 0 -> 2210973 bytes sqliteadmin/changelog.txt | 136 ++++++++ sqliteadmin/languages/catalan.lng | 325 +++++++++++++++++ sqliteadmin/languages/czech.lng | 326 +++++++++++++++++ sqliteadmin/languages/danish.lng | 316 +++++++++++++++++ sqliteadmin/languages/dutch.lng | 327 ++++++++++++++++++ sqliteadmin/languages/english.lng | 316 +++++++++++++++++ sqliteadmin/languages/french.lng | 326 +++++++++++++++++ sqliteadmin/languages/greek.lng | 316 +++++++++++++++++ sqliteadmin/languages/hungarian.lng | 325 +++++++++++++++++ sqliteadmin/languages/italian.lng | 325 +++++++++++++++++ sqliteadmin/languages/polish.lng | 327 ++++++++++++++++++ sqliteadmin/languages/portugues_br.lng | 325 +++++++++++++++++ sqliteadmin/languages/russian.bak | 325 +++++++++++++++++ sqliteadmin/languages/russian.lng | 325 +++++++++++++++++ sqliteadmin/languages/simplified_chinese.lng | 325 +++++++++++++++++ sqliteadmin/languages/spanish.lng | 325 +++++++++++++++++ sqliteadmin/languages/traditional_chinese.lng | 326 +++++++++++++++++ sqliteadmin/languages/turkish.lng | 326 +++++++++++++++++ sqliteadmin/sqlite.dll | Bin 0 -> 213504 bytes sqliteadmin/sqlite3.dll | Bin 0 -> 378743 bytes sqliteadmin/sqliteadmin.exe | Bin 0 -> 3950592 bytes 52 files changed, 7147 insertions(+), 16 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 GeekHunter/GeekHunter.sln create mode 100644 GeekHunter/GeekHunter/App.config create mode 100644 GeekHunter/GeekHunter/Candidate.cs create mode 100644 GeekHunter/GeekHunter/DataService.cs create mode 100644 GeekHunter/GeekHunter/GeekHunter.csproj create mode 100644 GeekHunter/GeekHunter/Program.cs create mode 100644 GeekHunter/GeekHunter/Properties/AssemblyInfo.cs create mode 100644 GeekHunter/GeekHunter/SQLiteProcessor.cs create mode 100644 GeekHunter/GeekHunter/Skill.cs create mode 100644 GeekHunter/GeekHunterUI/App.config create mode 100644 GeekHunter/GeekHunterUI/App.xaml create mode 100644 GeekHunter/GeekHunterUI/App.xaml.cs create mode 100644 GeekHunter/GeekHunterUI/GeekHunterUI.csproj create mode 100644 GeekHunter/GeekHunterUI/MainViewModel.cs create mode 100644 GeekHunter/GeekHunterUI/MainWindow.xaml create mode 100644 GeekHunter/GeekHunterUI/MainWindow.xaml.cs create mode 100644 GeekHunter/GeekHunterUI/Properties/AssemblyInfo.cs create mode 100644 GeekHunter/GeekHunterUI/Properties/Resources.Designer.cs create mode 100644 GeekHunter/GeekHunterUI/Properties/Resources.resx create mode 100644 GeekHunter/GeekHunterUI/Properties/Settings.Designer.cs create mode 100644 GeekHunter/GeekHunterUI/Properties/Settings.settings create mode 100644 GeekHunter/UnitTestGeekHunter/DataProviderTests.cs create mode 100644 GeekHunter/UnitTestGeekHunter/Properties/AssemblyInfo.cs create mode 100644 GeekHunter/UnitTestGeekHunter/UnitTestGeekHunter.csproj create mode 100644 GeekHunter/UnitTestGeekHunter/packages.config create mode 100644 sqlite3.exe create mode 100644 sqliteadmin.zip create mode 100644 sqliteadmin/changelog.txt create mode 100644 sqliteadmin/languages/catalan.lng create mode 100644 sqliteadmin/languages/czech.lng create mode 100644 sqliteadmin/languages/danish.lng create mode 100644 sqliteadmin/languages/dutch.lng create mode 100644 sqliteadmin/languages/english.lng create mode 100644 sqliteadmin/languages/french.lng create mode 100644 sqliteadmin/languages/greek.lng create mode 100644 sqliteadmin/languages/hungarian.lng create mode 100644 sqliteadmin/languages/italian.lng create mode 100644 sqliteadmin/languages/polish.lng create mode 100644 sqliteadmin/languages/portugues_br.lng create mode 100644 sqliteadmin/languages/russian.bak create mode 100644 sqliteadmin/languages/russian.lng create mode 100644 sqliteadmin/languages/simplified_chinese.lng create mode 100644 sqliteadmin/languages/spanish.lng create mode 100644 sqliteadmin/languages/traditional_chinese.lng create mode 100644 sqliteadmin/languages/turkish.lng create mode 100644 sqliteadmin/sqlite.dll create mode 100644 sqliteadmin/sqlite3.dll create mode 100644 sqliteadmin/sqliteadmin.exe diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c9a181 --- /dev/null +++ b/.gitignore @@ -0,0 +1,242 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +[Xx]64/ +[Xx]86/ +[Bb]uild/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml + +# TODO: Un-comment the next line if you do not want to checkin +# your web deploy settings because they may include unencrypted +# passwords +#*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# LightSwitch generated files +GeneratedArtifacts/ +ModelManifest.xml + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/GeekHunter.sqlite b/GeekHunter.sqlite index 7401c480c161772bdd302891cdcd65352cd4852c..48632fc27d0e5db7c6e1e05af8fbb108004559d2 100644 GIT binary patch delta 533 zcmY+A&1(}u7{+I^GfBIfnP-!wlu|Hj4q~9SwCT}HTUTieDWqHRgB~_ys7u2xg!NE7 zG{JwM(qlo|n|dGBI|F*Z^Yr)W~JFigO0bds5ej>QPPk5QKq){&=nVbO&VXM@=`49 zMm~`{v<}n=e&Q=W;vHV&7%z}v50BBsUEIbhYWa2dNFJYGix0gjBXhNG+Ec@9JsL*Y zQlON+9_3kC&7wO9TNKErgI delta 225 zcmZozz}V2hI6+!agn@y91&CpQZK95`un2>mz;9ll5HsI;2L5b*Nxt=)4FzoZHm~Ok zWfWlJpUlAjng0&|asKW6EBGgG7F1ZoH+h>}W_?L&UWr0levv{+Myf)1eo;<}LU?8h zkeQm4!NkfS+321XSejZ?nOUrmsE}NgUtFwPkds&f)RC*;l~|S-oLrPyP@<5NnN*Zm zRH=}XTAZ1lmzttblCMylnOl&PnN|rlIyom3Xp?R+$ZTOY76wWAkjkRW{LS;^!vq-F KHh + + + + + diff --git a/GeekHunter/GeekHunter/Candidate.cs b/GeekHunter/GeekHunter/Candidate.cs new file mode 100644 index 0000000..a202383 --- /dev/null +++ b/GeekHunter/GeekHunter/Candidate.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekHunter +{ + public class Candidate + { + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + + public List SkillIds { get; set; } + public string SkillNames { get; set; } + } + + +} diff --git a/GeekHunter/GeekHunter/DataService.cs b/GeekHunter/GeekHunter/DataService.cs new file mode 100644 index 0000000..5eb316f --- /dev/null +++ b/GeekHunter/GeekHunter/DataService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekHunter +{ + public class DataService + { + private readonly ISQLiteProcessor sqLiteProcessor; + + public DataService(ISQLiteProcessor sqLiteProcessor) + { + this.sqLiteProcessor = sqLiteProcessor; + } + + public IList GetAllCandidates() + { + var candidates = sqLiteProcessor.GetAllCandidates(); + foreach (var candidate in candidates) + { + var skills = sqLiteProcessor.GetCandidateSkills(candidate.Id); + + List ids = skills.Keys.ToList(); + List names = skills.Values.ToList(); + + candidate.SkillNames = string.Join(",", names); + candidate.SkillIds = ids; + } + return candidates; + } + + public IList GetAllSkills() { + return sqLiteProcessor.GetAllSkills(); + } + + public int CreateCandidate(string firstName, string lastName, IList skillIds ) + { + return sqLiteProcessor.CreateCandidateAndSkills(firstName, lastName, skillIds); + } + } +} diff --git a/GeekHunter/GeekHunter/GeekHunter.csproj b/GeekHunter/GeekHunter/GeekHunter.csproj new file mode 100644 index 0000000..5247814 --- /dev/null +++ b/GeekHunter/GeekHunter/GeekHunter.csproj @@ -0,0 +1,73 @@ + + + + + Debug + AnyCPU + {7C95021F-60EB-4900-AA34-9C7F720CCABA} + Exe + Properties + GeekHunter + GeekHunter + v4.5 + 512 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + ..\..\..\..\..\..\..\Program Files\System.Data.SQLite\2012\bin\System.Data.SQLite.dll + + + ..\..\..\..\..\..\..\Program Files\System.Data.SQLite\2012\bin\System.Data.SQLite.Linq.dll + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GeekHunter/GeekHunter/Program.cs b/GeekHunter/GeekHunter/Program.cs new file mode 100644 index 0000000..f1585a7 --- /dev/null +++ b/GeekHunter/GeekHunter/Program.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data.SQLite; +using System.Data.SQLite.Linq; + + + +namespace GeekHunter +{ + class Program + { + static void Main(string[] args) { + var path = "GeekHunter.sqlite"; + + var dataService = new DataService(new SQLiteProcessor()); + + IList candidates; + candidates = dataService.GetAllCandidates(); + + IList skills; + skills = dataService.GetAllSkills(); + + foreach (var candidate in candidates) { + Console.WriteLine(candidate.FirstName + " " + candidate.LastName + " " + candidate.SkillNames); + } + + foreach (var skill in skills) { + Console.WriteLine(skill.Id + " " + skill.Name); + } + Console.ReadKey(); + + dataService.CreateCandidate("Jane", "Doe", new List {1, 2, 3}); + } + } +} diff --git a/GeekHunter/GeekHunter/Properties/AssemblyInfo.cs b/GeekHunter/GeekHunter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..718ea1e --- /dev/null +++ b/GeekHunter/GeekHunter/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GeekHunter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GeekHunter")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7c95021f-60eb-4900-aa34-9c7f720ccaba")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: InternalsVisibleTo("UnitTestGeekHunter")] + diff --git a/GeekHunter/GeekHunter/SQLiteProcessor.cs b/GeekHunter/GeekHunter/SQLiteProcessor.cs new file mode 100644 index 0000000..2b08118 --- /dev/null +++ b/GeekHunter/GeekHunter/SQLiteProcessor.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Data.SQLite; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace GeekHunter +{ + public interface ISQLiteProcessor + { + int CreateCandidateAndSkills(string firstName, string lastName, IList skillIds); + Dictionary GetCandidateSkills(int candidateId); + IList GetAllCandidates(); + IList GetAllSkills(); + } + + public class SQLiteProcessor : ISQLiteProcessor + { + private string sqliteAddress; + + public SQLiteProcessor(string sqliteAddress = @"Data Source=C:\Users\Joe\Documents\GitHub\GeekHunters\GeekHunter.sqlite") + { + this.sqliteAddress = sqliteAddress; + } + + public int CreateCandidateAndSkills(string firstName, string lastName, IList skillIds) + { + var candidateId = GetAllCandidates().Max(c => c.Id) + 1; + CreateCandidate(candidateId, firstName, lastName); + foreach (int skillId in skillIds) + { + CreateCandidateSkills(candidateId, skillId); + + } + return candidateId; + } + + private void ExecuteNonQuery(string query) { + using (SQLiteConnection conn = new SQLiteConnection(sqliteAddress)) { + conn.Open(); + using (SQLiteCommand cmd = new SQLiteCommand(conn)) { + cmd.CommandText = query; + cmd.ExecuteNonQuery(); + } + } + } + + private void CreateCandidate(int id, string firstName, string LastName) + { + var query = $"insert into Candidate(id, firstname, lastname) values({id}, '{firstName}', '{LastName}')"; + + ExecuteNonQuery(query); + } + + private void CreateCandidateSkills(int Candidateid, int SkillId) { + var query = $"insert into CandidateSkill(CandidateId, SkillId) values({Candidateid}, {SkillId})"; + ExecuteNonQuery(query); + } + + + public Dictionary GetCandidateSkills(int candidateId) { + using (SQLiteConnection conn = new SQLiteConnection(sqliteAddress)) { + conn.Open(); + using (SQLiteCommand cmd = new SQLiteCommand(conn)) { + cmd.CommandText = $"select id, name from CandidateSkill join Skill on skill.Id = CandidateSkill.SkillId where CandidateId = {candidateId}"; + using (SQLiteDataReader reader = cmd.ExecuteReader()) { + Dictionary skills = new Dictionary(); + while (reader.Read()) { + var id = reader.GetInt32(0); + var name = reader.GetString(1); + + skills.Add(id, name); + } + return skills; + } + } + } + } + + public IList GetAllCandidates() { + using (SQLiteConnection conn = new SQLiteConnection(sqliteAddress)) + { + conn.Open(); + using (SQLiteCommand cmd = new SQLiteCommand(conn)) + { + cmd.CommandText = "select id, FirstName, LastName from Candidate"; + using (SQLiteDataReader reader = cmd.ExecuteReader()) { + IList candidates = new List(); + while (reader.Read()) { + candidates.Add(new Candidate { Id = reader.GetInt32(0), FirstName = reader.GetString(1), LastName = reader.GetString(2) }); + } + return candidates; + } + } + } + } + + public IList GetAllSkills() { + using (SQLiteConnection conn = new SQLiteConnection(sqliteAddress)) { + conn.Open(); + using (SQLiteCommand cmd = new SQLiteCommand(conn)) { + cmd.CommandText = "select Id, Name from Skill"; + using (SQLiteDataReader reader = cmd.ExecuteReader()) { + IList candidates = new List(); + while (reader.Read()) { + candidates.Add(new Skill { Id = reader.GetInt32(0), Name = reader.GetString(1) }); + } + return candidates; + } + } + } + } + } +} diff --git a/GeekHunter/GeekHunter/Skill.cs b/GeekHunter/GeekHunter/Skill.cs new file mode 100644 index 0000000..16c1fb0 --- /dev/null +++ b/GeekHunter/GeekHunter/Skill.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekHunter +{ + public class Skill + { + public int Id { get; set; } + public string Name { get; set; } + + public bool IsSelected { get; set; } + } +} diff --git a/GeekHunter/GeekHunterUI/App.config b/GeekHunter/GeekHunterUI/App.config new file mode 100644 index 0000000..d1428ad --- /dev/null +++ b/GeekHunter/GeekHunterUI/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/GeekHunter/GeekHunterUI/App.xaml b/GeekHunter/GeekHunterUI/App.xaml new file mode 100644 index 0000000..871c4f4 --- /dev/null +++ b/GeekHunter/GeekHunterUI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/GeekHunter/GeekHunterUI/App.xaml.cs b/GeekHunter/GeekHunterUI/App.xaml.cs new file mode 100644 index 0000000..e72120f --- /dev/null +++ b/GeekHunter/GeekHunterUI/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace GeekHunterUI +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/GeekHunter/GeekHunterUI/GeekHunterUI.csproj b/GeekHunter/GeekHunterUI/GeekHunterUI.csproj new file mode 100644 index 0000000..d4b7689 --- /dev/null +++ b/GeekHunter/GeekHunterUI/GeekHunterUI.csproj @@ -0,0 +1,115 @@ + + + + + Debug + AnyCPU + {A13F0EB3-3172-4A19-A4E3-30FD4D89BC63} + WinExe + Properties + GeekHunterUI + GeekHunterUI + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + {7C95021F-60EB-4900-AA34-9C7F720CCABA} + GeekHunter + + + + + \ No newline at end of file diff --git a/GeekHunter/GeekHunterUI/MainViewModel.cs b/GeekHunter/GeekHunterUI/MainViewModel.cs new file mode 100644 index 0000000..66e3683 --- /dev/null +++ b/GeekHunter/GeekHunterUI/MainViewModel.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using GeekHunter; + +namespace GeekHunterUI +{ + public class MainViewModel + { + private DataService dataServivce; + + public MainViewModel() + { + dataServivce = new DataService(new SQLiteProcessor()); + Skills = new ObservableCollection(); + Candidates = new ObservableCollection(); + dataServivce.GetAllSkills().ToList().ForEach(skill => Skills.Add(skill)); + + ReloadAllCandidates(); + } + public ObservableCollection Skills { get; private set; } + + internal void AddCandidate(string firstName, string lastName, List skillIds) + { + dataServivce.CreateCandidate(firstName, lastName, skillIds); + + Candidates.Clear(); + ReloadAllCandidates(); + } + + public ObservableCollection Candidates { get; private set; } + + public void SearchCandidate(List skillIds) + { + var searchResult = Candidates.Where(candidate => + { + return skillIds.All(requiredSkill => candidate.SkillIds.Contains(requiredSkill)); + }).ToList(); + + Candidates.Clear(); + + searchResult.ToList().ForEach(candidate => Candidates.Add(candidate)); + } + + public void ReloadAllCandidates() + { + Candidates.Clear(); + dataServivce.GetAllCandidates().ToList().ForEach(candidate => Candidates.Add(candidate)); + } + } +} diff --git a/GeekHunter/GeekHunterUI/MainWindow.xaml b/GeekHunter/GeekHunterUI/MainWindow.xaml new file mode 100644 index 0000000..5fecada --- /dev/null +++ b/GeekHunter/GeekHunterUI/MainWindow.xaml @@ -0,0 +1,50 @@ + + + + + +