コード例 #1
0
        protected override async Task SaveAsync(ApiChangeAction operation, object entity, bool commit = true)
        {
            if (operation == ApiChangeAction.Insert)
            {
                var clientPolicy = entity as ClientPolicy;
                clientPolicy.ClientPolicyId = MockData.ClientPolicies
                                              .Max(p => p.ClientPolicyId) + 1;

                MockData.AddRelatedData(clientPolicy);
                MockData.ClientPolicies.Add(clientPolicy);
            }

            await Task.FromResult(0);
        }
コード例 #2
0
        protected override async Task SaveAsync(ApiChangeAction operation, object entity, bool commit = true)
        {
            if (operation == ApiChangeAction.Insert)
            {
                var policyCoverage = entity as PolicyCoverage;
                policyCoverage.PolicyCoverageId = MockData.PolicyCoverages
                                                  .Max(p => p.PolicyCoverageId) + 1;

                MockData.AddRelatedData(policyCoverage);
                MockData.PolicyCoverages.Add(policyCoverage);
            }
            else if (operation == ApiChangeAction.Delete)
            {
                MockData.PolicyCoverages.Remove(entity as PolicyCoverage);
            }

            await Task.FromResult(0);
        }
コード例 #3
0
        protected override async Task SaveAsync(ApiChangeAction operation, object entity, bool commit = true)
        {
            if (operation == ApiChangeAction.Insert)
            {
                var policy = entity as Policy;
                policy.PolicyId = MockData.Policies.Max(p => p.PolicyId) + 1;

                MockData.AddRelatedData(policy);
                MockData.Policies.Add(policy);
            }
            else if (operation == ApiChangeAction.Update)
            {
                var newPolicy = entity as Policy;
                var oldPolicy = MockData.Policies
                                .First(p => p.PolicyId == newPolicy.PolicyId);

                MockData.AddRelatedData(newPolicy);
                MockData.Policies.Add(newPolicy);
                MockData.Policies.Remove(oldPolicy);
            }
            else if (operation == ApiChangeAction.Delete)
            {
                var policy = entity as Policy;
                MockData.Policies.Remove(policy);

                var policyCoverages = MockData.PolicyCoverages
                                      .Where(pc => pc.PolicyId == policy.PolicyId)
                                      .ToList();

                for (var i = 0; i < policyCoverages.Count; i++)
                {
                    MockData.PolicyCoverages.Remove(policyCoverages[i]);
                }
            }

            await Task.FromResult(0);
        }