From fe15df3d11c89d712823ff0ed17c520668564caa Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 7 Mar 2018 20:05:31 +0100 Subject: [PATCH] Added Applicants to Logic --- Logic/Logic.csproj | 2 ++ Logic/Swarm/Applicant.cs | 43 +++++++++++++++++++++++++++++++++++++++ Logic/Swarm/Applicants.cs | 14 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 Logic/Swarm/Applicant.cs create mode 100644 Logic/Swarm/Applicants.cs diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 223b325a..83126f21 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -438,6 +438,8 @@ + + diff --git a/Logic/Swarm/Applicant.cs b/Logic/Swarm/Applicant.cs new file mode 100644 index 00000000..063fbf15 --- /dev/null +++ b/Logic/Swarm/Applicant.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Basic.Types.Swarm; +using Swarmops.Database; +using Swarmops.Logic.Structure; + +namespace Swarmops.Logic.Swarm +{ + public class Applicant: BasicApplicant + { + private Applicant(BasicApplicant basic) : base(basic) + { + // private ctor + } + + static public Applicant FromBasic(BasicApplicant basic) + { + return new Applicant(basic); + } + + static public Applicant FromIdentity(int applicantId) + { + return FromBasic(SwarmDb.GetDatabaseForReading().GetApplicant(applicantId)); + } + + static private Applicant FromIdentityAggressive(int applicantId) + { + // "ForWriting" intentional - bypass lag to read instances in multi dbserver setup + return FromBasic(SwarmDb.GetDatabaseForWriting().GetApplicant(applicantId)); + } + + static public Applicant Create(Person person, Organization organization) + { + return + FromIdentityAggressive(SwarmDb.GetDatabaseForWriting() + .CreateApplicant(person.Identity, organization.Identity)); + } + } +} diff --git a/Logic/Swarm/Applicants.cs b/Logic/Swarm/Applicants.cs new file mode 100644 index 00000000..682386eb --- /dev/null +++ b/Logic/Swarm/Applicants.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Basic.Types.Swarm; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Swarm +{ + public class Applicants: PluralBase + { + } +}