Exemple #1
0
        public Task <bool> Handle(UpdatePatientAddressCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var existingPatient = _patientRepository.GetById(message.Id);

            if (existingPatient == null)
            {
                _bus.RaiseEvent(new DomainNotification(message.MessageType, "Patient not found."));
                return(Task.FromResult(false));
            }

            if (existingPatient.Id != message.Id)
            {
                _bus.RaiseEvent(new DomainNotification(message.MessageType,
                                                       "Patient identification does not match, please verify."));
                return(Task.FromResult(false));
            }

            var address = new Address.Builder().InCityOf(message.City).InTheDistrict(message.District)
                          .InTheState(message.State).WithNumber(message.Number).WithObservation(message.Observation)
                          .WithPostalCode(message.PostalCode).WithStreet(message.Street).Build();

            var patient = new Patient.Builder(existingPatient.Id).BornIn(existingPatient.BirthDate)
                          .Named(existingPatient.FullName).ThatLivesIn(address).WithCpf(existingPatient.Cpf)
                          .WithEmail(existingPatient.Email).WithGender(existingPatient.Gender).WithPhone(existingPatient.Phone)
                          .WithPhoto(existingPatient.Photo).WhichIsActive().WithHeartRate(existingPatient.HeartRate).Build();

            if (!patient.IsValid())
            {
                NotifyValidationErrors(patient.ValidationResult);
                return(Task.FromResult(false));
            }

            _patientRepository.Update(patient);

            if (Commit())
            {
                _bus.RaiseEvent(new PatientAddressUpdatedEvent(patient));
            }

            return(Task.FromResult(true));
        }
Exemple #2
0
        public void AddMarket([FromBody] JObject ProductObject)
        {
            Address address = new Address.Builder()
                              .SetEmail(ProductObject["Email"].ToString())
                              .SetPhoneNumber(ProductObject["PhoneNumber"].ToString())
                              .SetPrimaryAddress(ProductObject["PrimaryAddress"].ToString())
                              .SetSecondaryAddress(ProductObject["SecondaryAddress"].ToString())
                              .Build();

            Market market = new Market.Builder()
                            .SetName(ProductObject["Name"].ToString())
                            .SetDescription(ProductObject["Description"].ToString())
                            .SetAddress(address)
                            .Build();

            marketService.Save(market);
        }
        public void TestSaveManufacturer()
        {
            Address address = new Address.Builder()
                              .SetEmail("Test Email")
                              .SetPhoneNumber("Test PhoneNumber")
                              .SetWorkNumber("Test Work number")
                              .SetPrimaryAddress("Test Primary Address")
                              .SetSecondaryAddress("Test secondary address")
                              .Build();

            Manufacturer manufacturer = new Manufacturer.Builder()
                                        .SetName("Test Manfacturer")
                                        .SetLogo("Test Logo")
                                        .SetAddress(address)
                                        .Build();

            manufacturerService.Save(manufacturer);
        }
Exemple #4
0
        public static void Run()
        {
            PersonInformation.Builder personInformationBuilder = new PersonInformation.Builder();

            Person.Builder personBuilder = new Person.Builder();
            Person         person        = personBuilder.SetAge(28).SetName("Name").Build();


            Address.Builder address = new Address.Builder();
            address.SetFlatNo("2").SetLane("Lane").SetLandmark("Landmark");

            personInformationBuilder
            .SetPerson(personBuilder)
            .SetAddress(address)
            .Build();

            personInformationBuilder.GetPerson().GetAge();
        }
        public MerchantOrder.Builder GetOrder(int orderId)
        {
            CustomerInformation customerInformation = new CustomerInformation.Builder()
                                                      .WithTelephoneNumber("0204971111")
                                                      .WithInitials("J.D.")
                                                      .WithGender(Gender.M)
                                                      .WithEmailAddress("*****@*****.**")
                                                      .WithDateOfBirth("20-03-1987")
                                                      .Build();

            Address shippingDetails = new Address.Builder()
                                      .WithFirstName("John")
                                      .WithLastName("Doe")
                                      .WithStreet("Street")
                                      .WithHouseNumber("5")
                                      .WithHouseNumberAddition("a")
                                      .WithPostalCode("1234AB")
                                      .WithCity("Haarlem")
                                      .WithCountryCode(CountryCode.NL)
                                      .Build();

            Address billingDetails = new Address.Builder()
                                     .WithFirstName("John")
                                     .WithLastName("Doe")
                                     .WithStreet("Factuurstraat")
                                     .WithHouseNumber("5")
                                     .WithHouseNumberAddition("a")
                                     .WithPostalCode("1234AB")
                                     .WithCity("Haarlem")
                                     .WithCountryCode(CountryCode.NL)
                                     .Build();

            MerchantOrder.Builder order = new MerchantOrder.Builder()
                                          .WithMerchantOrderId(Convert.ToString(orderId))
                                          .WithDescription("An example description")
                                          .WithCustomerInformation(customerInformation)
                                          .WithShippingDetail(shippingDetails)
                                          .WithBillingDetail(billingDetails)
                                          .WithLanguage(Language.NL)
                                          .WithMerchantReturnURL(RETURN_URL)
                                          .WithInitiatingParty("LIGHTSPEED");

            return(order);
        }
Exemple #6
0
        public void MustCreateValidActivePatientWithAllAttributes()
        {
            // Arrange
            var address = new Address.Builder()
                          .InCityOf("Porto Alegre")
                          .InTheState("Rio Grande do Sul")
                          .WithPostalCode("91900420")
                          .WithStreet("Some Place")
                          .WithNumber("123")
                          .InTheDistrict("Some District")
                          .WithObservation("The Blue House")
                          .Build();


            // Act
            var patient = new Patient.Builder(Guid.NewGuid())
                          .Named("Johnny Bravo")
                          .WithCpf("58554143027")
                          .BornIn(new DateTime(1988, 09, 09))
                          .WithGender(Gender.Male)
                          .WithEmail("*****@*****.**")
                          .WhichIsActive()
                          .ThatLivesIn(address)
                          .WithPhoto(new byte[] { 0x00, 0x01, 0x02, 0x03 })
                          .WithPhone("555-5555")
                          .Build();

            // Assert
            Assert.Equal("Johnny Bravo", patient.FullName);
            Assert.Equal("58554143027", patient.Cpf);
            Assert.Equal(new DateTime(1988, 09, 09), patient.BirthDate);
            Assert.Equal(Gender.Male, patient.Gender);
            Assert.Equal("*****@*****.**", patient.Email);
            Assert.NotNull(patient.Address);
            Assert.True(patient.IsActive);
            Assert.NotNull(patient.Photo);
            Assert.Equal("555-5555", patient.Phone);
        }
Exemple #7
0
        public void MustCreateValidAddress()
        {
            // Arrange
            //Act
            var address = new Address.Builder()
                          .InCityOf("Porto Alegre")
                          .InTheState("Rio Grande do Sul")
                          .WithPostalCode("91900420")
                          .WithStreet("Some Place")
                          .WithNumber("123")
                          .InTheDistrict("Some District")
                          .WithObservation("The Blue House")
                          .Build();

            // Assert
            Assert.Equal("Porto Alegre", address.City);
            Assert.Equal("Rio Grande do Sul", address.State);
            Assert.Equal("91900420", address.PostalCode);
            Assert.Equal("Some Place", address.Street);
            Assert.Equal("123", address.Number);
            Assert.Equal("Some District", address.District);
            Assert.Equal("The Blue House", address.Observation);
        }
        public MerchantOrder GetOrder()
        {
            Money itemAmount = Money.FromDecimal(Currency.EUR, 99.99m);
            Money itemTax    = Money.FromDecimal(Currency.EUR, 4.99m);

            OrderItem orderItem = new OrderItem.Builder()
                                  .WithId("1")
                                  .WithQuantity(1)
                                  .WithName("Test product")
                                  .WithDescription("Description")
                                  .WithAmount(Money.FromDecimal(Currency.EUR, 10m))
                                  .WithTax(Money.FromDecimal(Currency.EUR, 1m))
                                  .WithItemCategory(ItemCategory.PHYSICAL)
                                  .WithVatCategory(VatCategory.LOW)
                                  .Build();

            CustomerInformation customerInformation = new CustomerInformation.Builder()
                                                      .WithTelephoneNumber("0204971111")
                                                      .WithInitials("J.D.")
                                                      .WithGender(Gender.M)
                                                      .WithEmailAddress("*****@*****.**")
                                                      .WithDateOfBirth("20-03-1987")
                                                      .Build();

            Address shippingDetails = new Address.Builder()
                                      .WithFirstName("John")
                                      .WithLastName("Doe")
                                      .WithStreet("Street")
                                      .WithHouseNumber("5")
                                      .WithHouseNumberAddition("a")
                                      .WithPostalCode("1234AB")
                                      .WithCity("Haarlem")
                                      .WithCountryCode(CountryCode.NL)
                                      .Build();

            Address billingDetails = new Address.Builder()
                                     .WithFirstName("John")
                                     .WithLastName("Doe")
                                     .WithStreet("Factuurstraat")
                                     .WithHouseNumber("5")
                                     .WithHouseNumberAddition("a")
                                     .WithPostalCode("1234AB")
                                     .WithCity("Haarlem")
                                     .WithCountryCode(CountryCode.NL)
                                     .Build();

            MerchantOrder order = new MerchantOrder.Builder()
                                  .WithMerchantOrderId("ORDID123")
                                  .WithDescription("An example description")
                                  .WithOrderItems(new List <OrderItem>(new OrderItem[] { orderItem }))
                                  .WithAmount(Money.FromDecimal(Currency.EUR, 99.99m))
                                  .WithCustomerInformation(customerInformation)
                                  .WithShippingDetail(shippingDetails)
                                  .WithBillingDetail(billingDetails)
                                  .WithLanguage(Language.NL)
                                  .WithMerchantReturnURL(RETURN_URL)
                                  .WithPaymentBrand(PaymentBrand.IDEAL)
                                  .WithPaymentBrandForce(PaymentBrandForce.FORCE_ONCE)
                                  .WithInitiatingParty("LIGHTSPEED")
                                  .Build();

            return(order);
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var order    = postProcessPaymentRequest.Order;
            var customer = order.Customer;


            var rokOrderItems = new List <OmniKassa.Model.Order.OrderItem>();

            foreach (var orderItem in order.OrderItems)
            {
                decimal amount = Decimal.Round(orderItem.UnitPriceInclTax, 2);
                decimal tax    = Decimal.Round(orderItem.UnitPriceInclTax - orderItem.UnitPriceExclTax, 2);

                var rokOrderItem = new OmniKassa.Model.Order.OrderItem.Builder()
                                   .WithId(orderItem.OrderItemGuid.ToString())
                                   .WithQuantity(orderItem.Quantity)
                                   .WithName(orderItem.Product.Name)
                                   .WithDescription(orderItem.Product.ShortDescription)
                                   .WithAmount(Money.FromDecimal(OmniKassa.Model.Enums.Currency.EUR, amount))
                                   .WithTax(Money.FromDecimal(OmniKassa.Model.Enums.Currency.EUR, tax))
                                   .WithItemCategory(ItemCategory.PHYSICAL)
                                   .WithVatCategory(VatCategory.LOW)
                                   .Build();

                rokOrderItems.Add(rokOrderItem);
            }

            CustomerInformation rokCustomerInformation = new CustomerInformation.Builder()
                                                         .WithTelephoneNumber(customer.BillingAddress.PhoneNumber)
                                                         .WithEmailAddress(customer.Email)
                                                         .Build();

            Address rokShippingDetails = new Address.Builder()
                                         .WithFirstName(customer.ShippingAddress.FirstName)
                                         .WithLastName(customer.ShippingAddress.LastName)
                                         .WithStreet(customer.ShippingAddress.Address1)
                                         .WithHouseNumber(customer.ShippingAddress.Address2)
                                         .WithPostalCode(customer.ShippingAddress.ZipPostalCode)
                                         .WithCity(customer.ShippingAddress.City)
                                         .WithCountryCode(CountryCode.NL)
                                         .Build();

            Address rokBillingDetails = new Address.Builder()
                                        .WithFirstName(customer.BillingAddress.FirstName)
                                        .WithLastName(customer.BillingAddress.LastName)
                                        .WithStreet(customer.BillingAddress.Address1)
                                        .WithHouseNumber(customer.BillingAddress.Address2)
                                        .WithPostalCode(customer.BillingAddress.ZipPostalCode)
                                        .WithCity(customer.BillingAddress.City)
                                        .WithCountryCode(CountryCode.NL)
                                        .Build();

            var rokOrder = new MerchantOrder.Builder()
                           .WithMerchantOrderId(order.CustomOrderNumber)
                           .WithDescription(order.CustomOrderNumber)
                           .WithOrderItems(rokOrderItems)
                           .WithAmount(Money.FromDecimal(OmniKassa.Model.Enums.Currency.EUR, Decimal.Round(order.OrderTotal, 2)))
                           .WithCustomerInformation(rokCustomerInformation)
                           .WithShippingDetail(rokShippingDetails)
                           .WithBillingDetail(rokBillingDetails)
                           .WithLanguage(Language.NL)
                           .WithMerchantReturnURL(GetReturnUrl())
                           .Build();

            String redirectUrl = _raboOmniKassaPaymentManager.AnnounceMerchantOrder(rokOrder);

            Debug.WriteLine(redirectUrl);

            _httpContextAccessor.HttpContext.Response.Redirect(redirectUrl);
        }
            public Builder SetAddress(Address.Builder a)
            {
                addressBuilder = a;

                return(this);
            }