public IEnumerable<Contact> ReadAllContacts(int? categoryId = default(int?)) { string query = "SELECT c.Id, Name, AddressId, a.StreetAndNumber, a.ZipCode, a.City, Gender, Blocked, BirthDay, Phone, Mobile FROM Contacts c INNER JOIN Addresses a ON a.Id = AddressId"; List<Contact> contactsTemp = new List<Contact>(); using (SqlConnection conn = GetConnection()) { SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Contact loadingContact = new Contact(); loadingContact.ContactId = reader.GetInt32(0); loadingContact.Name = reader.GetString(1); Address adres = new Address(); adres.AddressId = reader.GetInt32(2); adres.StreetAndNumber = reader.GetString(3); adres.Zipcode = (short)reader.GetInt16(4); //kan fout geven adres.City = reader.GetString(5); loadingContact.Adress = adres; byte genderInt = reader.GetByte(6);// blijkbaar met eem byte if (genderInt == 1) loadingContact.Gender = Gender.Male; else loadingContact.Gender = Gender.Female; loadingContact.Blocked = reader.GetBoolean(7); loadingContact.Birthday = reader.GetDateTime(8); loadingContact.Phone = reader.IsDBNull(9) ? null : reader.GetString(9); loadingContact.Mobile = reader.IsDBNull(10) ? null : reader.GetString(10); contactsTemp.Add(loadingContact); } } return contactsTemp; }
public ActionResult EditAddress(Address address) { var user = AuthHelper.GetUser(HttpContext, _userRepository); address.ModifiedDate = DateTime.Now; address.rowguid = Guid.NewGuid(); if (user != null) { _addressRepository.SaveToAddress(address); _addressCustomerRepository.SaveToCustomerAddress(_addressCustomerRepository.BindCustomerAddress(user, address)); } return RedirectToAction("ProfileUser", "Account"); }
public ActionResult ChangeAddress(Address address) { var command = new ChangeCustomerAddressCommand( address.Id, address.AddressLine1, address.AddressLine2, address.City, address.StateProvince, address.PostalCode, address.CountryRegion); this.commandProcessor.Process(command); return View(address); }
public ActionResult AddressChange(Address viewModel) { var command = new ChangeCustomerAddressCommand( viewModel.Id, viewModel.AddressLine1, viewModel.AddressLine2, viewModel.City, viewModel.StateProvince, viewModel.PostalCode, viewModel.CountryRegion); this.commandProcessor.Process(command); return View(viewModel); }
public static Importer Create(Guid notiificationId, Guid id, Business business = null, Address address = null, string name = "AnyName") { if (business == null) { business = ComplexTypeFactory.Create<Business>(); ObjectInstantiator<Business>.SetProperty(x => x.Name, name, business); } if (address == null) { address = ComplexTypeFactory.Create<Address>(); } var importer = new Importer(notiificationId, address, business, ComplexTypeFactory.Create<Contact>()); EntityHelper.SetEntityId(importer, id); return importer; }
public ActionResult AddressChange(Address viewModel) { var command = new ChangeCustomerAddressCommand( viewModel.Id, viewModel.AddressLine1, viewModel.AddressLine2, viewModel.City, viewModel.StateProvince, viewModel.PostalCode, viewModel.CountryRegion); var results = this.commandProcessor.Process(command); if (results.Success) { return this.RedirectToAction(x => x.Index()); } return View(viewModel); }
public static Producer Create(Guid id, Business business = null, Address address = null, string name = "AnyName") { var producer = ObjectInstantiator<Producer>.CreateNew(); EntityHelper.SetEntityId(producer, id); if (business == null) { business = ComplexTypeFactory.Create<Business>(); ObjectInstantiator<Business>.SetProperty(x => x.Name, name, business); } if (address == null) { address = ComplexTypeFactory.Create<Address>(); } ObjectInstantiator<Producer>.SetProperty(x => x.Business, business, producer); ObjectInstantiator<Producer>.SetProperty(x => x.Address, address, producer); return producer; }
public async Task CanModifyProducer() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = new Address("address1", string.Empty, "town", string.Empty, string.Empty, "country"); var business = ObjectFactory.CreateEmptyProducerBusiness(); var contact = new Contact(string.Empty, String.Empty, String.Empty, String.Empty); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var producerCollection = new ProducerCollection(notification.Id); var producer = producerCollection.AddProducer(business, address, contact); context.Producers.Add(producerCollection); await context.SaveChangesAsync(); var updateProducer = producerCollection.GetProducer(producer.Id); var newAddress = new Address("address1", string.Empty, "town", string.Empty, string.Empty, "country"); updateProducer.Address = newAddress; await context.SaveChangesAsync(); var newAddress1 = await context.Database.SqlQuery<string>("SELECT [Address1] FROM [Notification].[Producer] WHERE Id = @id", new SqlParameter("id", producer.Id)).SingleAsync(); Assert.Equal("address1", newAddress1); context.DeleteOnCommit(producer); context.DeleteOnCommit(producerCollection); context.DeleteOnCommit(notification); await context.SaveChangesAsync(); }
public void Validate_AddressWithNoPostcode_GeneratesListOfErrors() { var address = new Address(); var result = new AddressValidator().Validate(address); Assert.That(result.Errors.Count, Is.EqualTo(1)); }
public void ProcessPayment(List<ShoppingCartNamedElement> shoppingCartNamedElements) { this.eventPublisher.Publish(new PaymentBeginEvent() { PaymentGuid = paymentGuid }); if (shoppingCartNamedElements == null || shoppingCartNamedElements.Count == 0 || boughtProducts.Count == 0) { this.eventPublisher.Publish(new PaymentFailedEvent() { PaymentGuid = paymentGuid, FailureCode = "EMPTY", FailureMessage = "Shopping cart was empty" }); return; } const string merchant = "NEBRTEST"; const string merchantKey = "NEBRTEST123123"; const string serviceCode = "OTCTEST"; const string localReference = "test_002"; PaymentEngineService paymentEngineService = new PaymentEngineService(); paymentEngineService.Url = "https://tpe-test.dev.cdc.nicusa.com/paymentengine/services/PaymentEngineService"; WSOrderContext wsOrderContext = paymentEngineService.makeNewOrder(merchant, merchantKey, serviceCode); Orders order = wsOrderContext.order; order.localRef = localReference; order.originId = 1; WSItemsContext wsItemsContext = wsOrderContext.items; wsItemsContext.items = new WSItemContext[shoppingCartNamedElements.Count]; int itemCount = 0; foreach (var shoppingCartNamedElement in shoppingCartNamedElements) { wsItemsContext.items[itemCount] = new WSItemContext(); wsItemsContext.items[itemCount].item = new Item(); wsItemsContext.items[itemCount].item.itemTypeId = 1; wsItemsContext.items[itemCount].item.itemTypeIdSpecified = true; wsItemsContext.items[itemCount].item.itemClassId = 2; wsItemsContext.items[itemCount].item.itemClassIdSpecified = true; wsItemsContext.items[itemCount].item.sku = shoppingCartNamedElement.ProductName; wsItemsContext.items[itemCount].item.instanceId = shoppingCartNamedElement.ProductName + shoppingCartNamedElement.ProductId; wsItemsContext.items[itemCount].item.unitPrice = boughtProducts.Single(x => x.Id == shoppingCartNamedElement.ProductId).Price; wsItemsContext.items[itemCount].item.unitPriceSpecified = true; wsItemsContext.items[itemCount].item.quantity = shoppingCartNamedElement.Quantity; wsItemsContext.items[itemCount].item.quantitySpecified = true; wsItemsContext.items[itemCount].item.description = shoppingCartNamedElement.ProductName; itemCount++; } WSCustomerContext wsCustomerContext = wsOrderContext.customer; Address deliveryAddress = new Address(); deliveryAddress.zip = "123456"; wsOrderContext.paymentImplement.type = 1; wsOrderContext.paymentImplement.creditCard = new WSCreditCardContext(); WSCreditCardContext wsCreditCardContext = wsOrderContext.paymentImplement.creditCard; wsCreditCardContext.creditCard = new CreditCard(); wsCreditCardContext.creditCard.nameOnCard = "TOMTOM AIS"; wsCreditCardContext.creditCard.creditCardTypeId = 1; wsCreditCardContext.creditCard.creditCardTypeIdSpecified = true; wsCreditCardContext.creditCard.useCustomerAddress = "N"; wsCreditCardContext.textCardNumber = "4005550000000019"; wsCreditCardContext.dateExpirationDate = DateTime.Now.AddYears(3); wsCreditCardContext.dateExpirationDateSpecified = true; wsCreditCardContext.trackData = ";4005550000000019=12105101193010877?9"; Address billingAddress = new Address(); billingAddress.address1 = deliveryAddress.address1; billingAddress.zip = deliveryAddress.zip; wsCreditCardContext.address = billingAddress; VerificationsContext verificationsContext = paymentEngineService.submitOrder(merchant, merchantKey, wsOrderContext); if (verificationsContext.response.isFailure) { this.eventPublisher.Publish(new PaymentFailedEvent() { PaymentGuid = paymentGuid, FailureCode = verificationsContext.response.failureCode, FailureMessage = verificationsContext.response.failureMessage }); return; } BaseResponse completeOrderResponse = paymentEngineService.completeOrderWithOrderId(merchant, merchantKey, order.orderId, true); if (completeOrderResponse.response.isFailure) { this.eventPublisher.Publish(new PaymentFailedEvent() { PaymentGuid = paymentGuid, FailureCode = completeOrderResponse.response.failureCode, FailureMessage = completeOrderResponse.response.failureMessage }); return; } this.eventPublisher.Publish(new PaymentSucceededEvent() { PaymentGuid = paymentGuid }); }
static void Main(string[] args) { var reader = new ObjectRandomizer(); Domain.Address domObj = new Domain.Address(); reader.generateObjectRandomData<Domain.Address>(domObj); Domain.Company compObj = new Domain.Company(); reader.generateObjectRandomData<Domain.Company>(compObj); var property = Builder<Domain.Property> .CreateNew() .With(p => p.ConstructionStatus = Randomizer.Property.GenerateRandomPropertyBuildingStatus()) .And(p => p.CountryCode = Randomizer.Address.GenerateRandomCountryCode()) .And(p=> p.Addresses = (List<Domain.Address>)Builder<Domain.Address> .CreateListOfSize(4) .All().With(a => a.FullAddress = Randomizer.Address.GenerateRandomAddress()) .All().With(a => a.Country = Randomizer.Address.GenerateRandomCountry()) .Random(2).With(a=>a.Suite = Randomizer.Number.RandomIntMinMax(101,505).ToString()) .Random(2).With(a => a.Suite = null) .Build()) .Build(); int maxElements; var mockData = Builder<Domain.Property> .CreateListOfSize(20) .All().With(p => p.PropertyID = Randomizer.Number.RandomIntMinMax(1, 9999999)) .With(p => p.CountryCode = Randomizer.Address.GenerateRandomCountry()) .With(p => p.Addresses = (List<Domain.Address>)Builder<Domain.Address> .CreateListOfSize(Randomizer.Number.RandomIntMinMaxOut(2, 50, out maxElements)) .All() .With(a => a.FullAddress = Randomizer.Address.GenerateRandomAddress()) .With(a => a.Country = Randomizer.Address.GenerateRandomCountry()) .Random(Randomizer.Number.RandomIntMinMax(1, maxElements/2)).With(a => a.Suite = Randomizer.Number.RandomIntMinMax(101, 505).ToString()) .Random(Randomizer.Number.RandomIntMinMax(1, maxElements / 2)).With(a => a.Suite = null) .Build()) .Random(2).With(p=>p.Addresses = new List<Domain.Address>()) .TheFirst(5).With(p => p.ConstructionStatus = null) .TheNext(15).With(p => p.ConstructionStatus = Randomizer.Property.GenerateRandomPropertyBuildingStatus()) .Build(); var json = JsonConvert.SerializeObject(mockData); reader.generateObjectRandomData<Domain.Property>(property); Type t = typeof(Domain.Property); MethodInfo[] methods = t.GetMethods(); MemberInfo[] members = t.GetMembers(); FieldInfo[] fields = t.GetFields(); PropertyInfo[] properties = t.GetProperties(); //var properties = Builder<Domain.Property> // .CreateListOfSize(500) // .All() // .With(p => p.ConstructionStatus = Randomizer.Property.GenerateRandomPropertyBuildingStatus()) // .And(p => p.CountryCode = Randomizer.Address.GenerateRandomCountryCode()) // .Build(); var contacts = Builder<Contact> .CreateListOfSize(700) .All() .With(c => c.FirstName = Randomizer.Person.GenerateRandomFirstName()) .And(c => c.LastName = Randomizer.Person.GenerateRandomLastName()) .And(c => c.BirthDate = Randomizer.Date.GenerateRandomBirthdateMinAge(18)) .And(c => c.EmailAddress = Randomizer.Person.GenerateRandomEmailForName(c.FirstName)) .And(c => c.PhoneNumber = Randomizer.Person.GenerateRandomPhone()) .Build(); }
public Contact ReadContact(int id) { string query = "SELECT c.Id, Name, AddressId, a.StreetAndNumber, a.ZipCode, a.City, Gender, Blocked, BirthDay, Phone, Mobile FROM Contacts c INNER JOIN Addresses a ON a.Id = AddressId WHERE c.Id = @contactId"; Contact loadingContact = new Contact(); using (SqlConnection conn = GetConnection()) { SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@contactId", id); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); loadingContact.ContactId = reader.GetInt32(0); loadingContact.Name = reader.GetString(1); Address adres = new Address(); adres.AddressId = reader.GetInt32(2); adres.StreetAndNumber = reader.GetString(3); adres.Zipcode = (short)reader.GetInt16(4); //kan fout geven adres.City = reader.GetString(5); loadingContact.Adress = adres; byte genderInt = reader.GetByte(6);// blijkbaar met eem byte if (genderInt == 1) loadingContact.Gender = Gender.Male; else loadingContact.Gender = Gender.Female; loadingContact.Blocked = reader.GetBoolean(7); loadingContact.Birthday = reader.GetDateTime(8); loadingContact.Phone = reader.IsDBNull(9) ? null : reader.GetString(9); loadingContact.Mobile = reader.IsDBNull(10) ? null : reader.GetString(10); } return loadingContact; }
public Client(string firstName, string lastName, string phoneNumber, string email, string documentNumber, DateTime birthDate, Address address) { FirstName = firstName; LastName = lastName; PhoneNumber = phoneNumber; Email = email; DocumentNumber = documentNumber; BirthDate = birthDate; Address = address; }