Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //TODO validatie van de ingevoerde gegevens

            this.Cursor = Cursors.WaitCursor;

            try
            {
                VerhuisDeelnemerCommand command = new VerhuisDeelnemerCommand
                {
                    CorrelationId        = Guid.NewGuid(),
                    Id                   = _id,
                    Version              = _version,
                    Straat               = straatTextbox.Text,
                    Huisnummer           = Convert.ToInt32(huisnummerTextbox.Text),
                    HuisnummerToevoeging = toevoegingTextbox.Text.Length > 0 ? toevoegingTextbox.Text : null,
                    Postcode             = postcodeTextbox.Text,
                    Plaats               = plaatsTextbox.Text
                };
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:29713");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    string uri = string.Format("/api/deelnemer/{0}/verhuis", _id.ToString("D"));
                    HttpResponseMessage response = client.PutAsJsonAsync(uri, command).Result;

                    // niet gevonden apart afhandelen
                    if (response.StatusCode == HttpStatusCode.NotFound)
                    {
                        MessageBox.Show(this, "Deelnemer niet gevonden.");
                    }
                    else
                    {
                        // checken op 200-OK
                        response.EnsureSuccessStatusCode();
                    }
                }

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
 public void Verhuis(VerhuisDeelnemerCommand command)
 {
     ApplyChange(new DeelnemerVerhuisd
     {
         RoutingKey           = "Deelnemer.Verhuisd",
         CorrelationId        = command.CorrelationId,
         Id                   = command.Id,
         Nummer               = this.Nummer,
         Straat               = command.Straat,
         Huisnummer           = command.Huisnummer,
         HuisnummerToevoeging = command.HuisnummerToevoeging,
         Postcode             = command.Postcode,
         Plaats               = command.Plaats
     });
 }
Пример #3
0
        public HttpResponseMessage Verhuis(Guid id, [FromBody] VerhuisDeelnemerCommand command)
        {
            Domain.Deelnemer.Deelnemer deelnemer;
            try
            {
                deelnemer = _repo.GetById(id);
            }
            catch (AggregateNotFoundException ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            deelnemer.Verhuis(command);

            _repo.Save(deelnemer, command.Version);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public HttpResponseMessage Verhuis(Guid id, [FromBody] VerhuisDeelnemerCommand command)
        {
            var repo = new EventSourcedAggregateRepository <PensioenSysteem.Domain.Deelnemer.Deelnemer>(
                new FileEventStore(new RabbitMQEventPublisher()));

            Domain.Deelnemer.Deelnemer deelnemer;
            try
            {
                deelnemer = repo.GetById(id);
            }
            catch (AggregateNotFoundException ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            deelnemer.Verhuis(command);

            repo.Save(deelnemer, command.Version);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }