Пример #1
0
        private static Task <bool> HandleCreateAapAsync(CreateAap command)
        {
            bool successful = false;

            if (command.AapToCreate != null)
            {
                Console.WriteLine($"Creating animal {command.AapToCreate.AapNaam}: {JsonConvert.SerializeObject(command.AapToCreate)}");
                successful = ApenProvider.AddAap(command.AapToCreate);
            }

            return(Task.FromResult(successful));
        }
Пример #2
0
        /*
         * private static GetApenResponse HandleGetApenRequest(GetApenRequest request)
         * {
         *  GetApenResponse response = new GetApenResponse { CorrelationId = request.RequestId };
         *
         *  if (request.RequestId != Guid.Empty)
         *  {
         *      foreach (var aap in ApenProvider.GetApen()) response.Apen.Add(aap);
         *      response.Success = true;
         *  }
         *  else
         *  {
         *      response.ErrorMessage = "Received request without correlation identifier";
         *  }
         *
         *  return response;
         * }
         */

        private static void Seed()
        {
            Console.WriteLine("Starting Seed...");
            IList <Aap> apen = ApenProvider.GetApen().ToList();

            if (!apen.Any())
            {
                Console.WriteLine("Writing Seed data...");

                var aap0 = ApenProvider.GetAap(0);
                if (aap0 == null)
                {
                    ApenProvider.AddAap(new Aap {
                        Id = 0, AapNaam = "Bokito", Soort = ApenSoort.Gorilla
                    });
                }

                var aap1 = ApenProvider.GetAap(1);
                if (aap1 == null)
                {
                    ApenProvider.AddAap(new Aap {
                        Id = 1, AapNaam = "King Kong", Soort = ApenSoort.Primaat
                    });
                }

                var aap2 = ApenProvider.GetAap(2);
                if (aap2 == null)
                {
                    ApenProvider.AddAap(new Aap {
                        Id = 2, AapNaam = "Johannes", Soort = ApenSoort.Sim
                    });
                }
            }
            else
            {
                Console.WriteLine("Seed data was already written...");
            }
        }