Exemple #1
0
        public ActionResult AddAdress(AdressViewModel NewAdress)
        {
            if (ModelState.IsValid)
            {
                var adress = new Adress
                {
                    AdressId     = Guid.NewGuid(),
                    City         = NewAdress.City,
                    StreetName   = NewAdress.StreetName,
                    PostalNumber = NewAdress.PostalNumber,
                    Country      = NewAdress.Country,
                    LastUpdated  = DateTime.Now
                };

                Repository.Add(adress);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(PartialView(NewAdress));
            }
        }
        public Task Handle(RegisterNewAdressCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.CompletedTask);
            }

            var adress = new Address(message.Street, message.Number, message.Cep, message.Complement, message.City, message.State, message.Neighborhood);

            _adressRepository.Add(adress);

            if (Commit())
            {
                Bus.RaiseEvent(new AdressRegisteredEvent(message.AddressId, message.Street, message.Number, message.Cep, message.Complement, message.City, message.State, message.Neighborhood));
            }

            return(Task.CompletedTask);
        }