//Constructor public Policy() { PolicyNo = string.Format("P{0:0000}", policyCounter); activeState = new Active(this); lapsedState = new Lapsed(this); terminatedState = new Terminated(this); ++policyCounter; }
public Task <Response <PolicyState> > PolicyGetAsync(string policyId) { var state = new PolicyState() { Amount = 100000, BusinessTime = DateTimeOffset.Now, Duration = 100, Id = policyId }; return(Task.FromResult(ResponseCodes.OK(state))); }
public Task <Response <ICollection <PolicyState> > > PolicyGetAsync() { var state = new PolicyState() { Amount = 100000, BusinessTime = DateTimeOffset.Now, Duration = 100, Id = "1" }; var response = new Response <ICollection <PolicyState> >(200, new Dictionary <string, IEnumerable <string> > { { "Access-Control-Allow-Origin", new [] { "*" } } }, new [] { state }); return(Task.FromResult(response)); }
public void Given_policy_snapshot_When_restoring_Then_it_succeed() { var snapshot = new PolicyState { Amount = 5, BusinessTime = DateTimeOffset.Now, Duration = TimeSpan.FromDays(1), ExpiryDate = DateTimeOffset.Now.AddDays(10), IsExpired = false, Issued = true, IssueDate = DateTimeOffset.Now }; var policy = new InsurancePolicy(); policy.RestoreFromSnapshot(new SnapshotState <PolicyState> { State = snapshot, Address = new AggregateAddress <InsurancePolicy>(), Id = Guid.NewGuid().ToString(), Version = 100 }); }
public void GetByState(PolicyState state) { var now = DateTime.Now; switch (state) { case PolicyState.Pending: AttachCondition(e => e.StartDate > now); break; case PolicyState.Active: AttachCondition(e => e.EndDate >= now && e.StartDate <= now); break; case PolicyState.Expired: AttachCondition(e => e.EndDate < now); break; default: throw new NotImplementedException("Cannot define policy state"); } }
// State Pattern methods public void SetState(PolicyState state) { this.state = state; }
public Policy(List <PolicyCategory> policyProfiles, string title) { m_PolicyProfiles = policyProfiles; m_Title = title; m_Policystate = PolicyState.Enabled; }
public Policy() { m_PolicyProfiles = new List <PolicyCategory>(); m_Title = string.Empty; m_Policystate = PolicyState.Disabled; }