Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public void EditContact(Domain.Contact contact)
 {
     if (_db.Contact.Find(contact.Id) != null)
     {
         _db.Contact.Update(Mapper.Map(contact));
     }
 }
Ejemplo n.º 3
0
        public void CreateContact(Contact contactToInsert)
        {
            // stap 1: de querry implementeren.
              string adresQuery = "INSERT INTO Addresses (StreetAndNumber, ZipCode, City) VALUES (@streetAndNumber, @zipCode, @city);";
              string contacQuerry = "INSERT INTO Contacts (Name, AddressId, Gender, Blocked, BirthDay, Phone, Mobile) VALUES (@name, @addressId, @gender, @blocked, @birthDay, @phone, @mobile)";
              string indentityQuery = "SELECT SCOPE_IDENTITY()";
              // een connectie starten
              using (SqlConnection connectie = GetConnection())
              {
            connectie.Open();
            //sql command definieren
            //SqlCommand commando = new SqlCommand(contacQuerry, connectie);
            //paramenters aanpassen
            SqlCommand commando = new SqlCommand(adresQuery+indentityQuery, connectie);
            commando.Parameters.AddWithValue("@streetAndNumber", contactToInsert.Adress.StreetAndNumber);
            commando.Parameters.AddWithValue("@zipCode", contactToInsert.Adress.Zipcode);
            commando.Parameters.AddWithValue("@city", contactToInsert.Adress.City);
            //commando.ExecuteNonQuery();

            int id = Convert.ToInt32(commando.ExecuteScalar());

            commando = new SqlCommand(contacQuerry, connectie);
            commando.Parameters.AddWithValue("@name", contactToInsert.Name);
            commando.Parameters.AddWithValue("@addressId", id);//dummy waarde
            commando.Parameters.AddWithValue("@gender", contactToInsert.Gender);
            commando.Parameters.AddWithValue("@blocked", contactToInsert.Blocked);
            commando.Parameters.AddWithValue("@birthDay", contactToInsert.Birthday);
            commando.Parameters.AddWithValue("@phone", contactToInsert.Phone);
            commando.Parameters.AddWithValue("@mobile", contactToInsert.Mobile);
            commando.ExecuteNonQuery();

            connectie.Close();
              }
        }
        public async Task CreateCustomerFile_WithFileID_CreatesFileWithCorrectFileID()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy<UKCompetentAuthority>();

            Address address = new Address(
                "1 High Street",
                null,
                "Some town",
                "Some county",
                "Post code",
                new Country(Guid.NewGuid(), "UK - England"),
                "01234 567890",
                "*****@*****.**");

            Contact contact = new Contact("John", "Smith", "Manager");

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");
            organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, address);
            organisation.AddOrUpdateMainContactPerson(contact);

            Scheme scheme = new Scheme(organisation);
            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy<ObligationType>(),
                authority);

            int complianceYear = A.Dummy<int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy<Guid>(),
                A.Dummy<string>(),
                A.Dummy<List<MemberUploadError>>(),
                A.Dummy<decimal>(),
                complianceYear,
                scheme,
                A.Dummy<string>());

            memberUpload.Submit(A.Dummy<User>());

            List<MemberUpload> memberUploads = new List<MemberUpload>();
            memberUploads.Add(memberUpload);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy<User>());

            BySchemeCustomerFileGenerator generator = new BySchemeCustomerFileGenerator();
            ulong id = 12345;

            // Act
            var result = await generator.CreateAsync(id, invoiceRun);
            CustomerFile customerFile = result.IbisFile;

            // Assert
            Assert.Equal((ulong)12345, customerFile.FileID);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Triggers this instance.
 /// </summary>
 protected override void Trigger(Contact contact)
 {
     var chance = Random.Next(0, 70);
     if (chance == 1)
     {
         contact.TagLine = _quotes.SelectRandom();
     }
     else if (chance == 2)
     {
         contact.TagLine = "";
     }
 }
Ejemplo n.º 6
0
        public static externalDTO.Contact MapFromDomain(internalDTO.Contact contact)
        {
            var res = contact == null ? null : new externalDTO.Contact
            {
                Id            = contact.Id,
                PersonId      = contact.PersonId,
                Person        = PersonMapper.MapFromDomain(contact.Person),
                ContactTypeId = contact.ContactTypeId,
                ContactType   = ContactTypeMapper.MapFromDomain(contact.ContactType),
                ContactValue  = contact.ContactValue
            };


            return(res);
        }
Ejemplo n.º 7
0
        public static Data.Entities.Contact Map(Domain.Contact dmContact)
        {
            Data.Entities.Contact deContact = new Entities.Contact();
            deContact.Id         = dmContact.Id;
            deContact.FirstName  = dmContact.FirstName;
            deContact.MiddleName = dmContact.MiddleName;
            deContact.LastName   = dmContact.LastName;
            deContact.Mobile     = dmContact.Mobile;
            deContact.WorkPhone  = dmContact.WorkPhone;
            deContact.HomePhone  = dmContact.HomePhone;
            deContact.Email      = dmContact.Email;
            deContact.Created    = dmContact.Created;
            deContact.Modified   = dmContact.Modified;

            return(deContact);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new contact.
 /// </summary>
 public Contact CreateContact()
 {
     var result = new Contact();
     if (_random.Next(2) == 0)
     {
         result.Name = _maleFirstNames.SelectRandom() + " " + _lastNames.SelectRandom();
         result.Photo = ExtractPhoto(false);
     }
     else
     {
         result.Name = _femaleFirstNames.SelectRandom() + " " + _lastNames.SelectRandom();
         result.Photo = ExtractPhoto(true);
     }
     result.EmailAddress = result.Name.ToLowerInvariant().Replace(" ", ".") + "@hotmail.com";
     _behaviors.SelectRandom().ApplyTo(result);
     return result;
 }
        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();
        }
Ejemplo n.º 10
0
 protected abstract void Trigger(Contact contact);
Ejemplo n.º 11
0
 public void UpdateContact(Contact contactToUpdate)
 {
     string query = "UPDATE Contacts SET Name = @name, Gender = @gender, Blocked = @blocked, BirthDay = @birthDay, Phone = @phone, Mobile = @mobile WHERE Id = @contactId";
       using(SqlConnection conn = GetConnection())
       {
     conn.Open();
     SqlCommand cmd = new SqlCommand(query, conn);
     cmd.Parameters.AddWithValue("@name", contactToUpdate.Name);
     if(contactToUpdate.Gender == Gender.Male)
     {
       cmd.Parameters.AddWithValue("@gender", 1);
     }
     else
     {
       cmd.Parameters.AddWithValue("@gender", 2);
     }
     cmd.Parameters.AddWithValue("@blocked", contactToUpdate.Blocked);
     cmd.Parameters.AddWithValue("@birthDay", contactToUpdate.Birthday);
     cmd.Parameters.AddWithValue("@phone", contactToUpdate.Phone);
     cmd.Parameters.AddWithValue("@mobile", contactToUpdate.Mobile);
     cmd.Parameters.AddWithValue("@contactId", contactToUpdate.ContactId);
     cmd.ExecuteNonQuery();
     conn.Close();
       }
 }
Ejemplo n.º 12
0
 public void Add(Domain.Contact contact)
 {
     _db.Contact.Add(Mapper.Map(contact));
 }
        public async Task CreateCustomerFile_WithExceptionThrown_ReturnsError_AndNoCustomerFile()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy<UKCompetentAuthority>();

            Address address = new Address(
                "1 High Street",
                null,
                "Some town",
                "Some county",
                null, // A null value will cause the Ibis class to throw an exception.
                new Country(Guid.NewGuid(), "UK - England"),
                "01234 567890",
                "*****@*****.**");

            Contact contact = new Contact("John", "Smith", "Manager");

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");
            organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, address);
            organisation.AddOrUpdateMainContactPerson(contact);

            Scheme scheme = new Scheme(organisation);
            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy<ObligationType>(),
                authority);

            int complianceYear = A.Dummy<int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy<Guid>(),
                A.Dummy<string>(),
                A.Dummy<List<MemberUploadError>>(),
                A.Dummy<decimal>(),
                complianceYear,
                scheme,
                A.Dummy<string>());

            memberUpload.Submit(A.Dummy<User>());

            List<MemberUpload> memberUploads = new List<MemberUpload>();
            memberUploads.Add(memberUpload);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy<User>());

            BySchemeCustomerFileGenerator generator = new BySchemeCustomerFileGenerator();

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            // Assert
            Assert.Null(result.IbisFile);
            Assert.NotEmpty(result.Errors);
        }
        public async Task CreateCustomerFile_WithNonUkAddress_ConcatenatesPostCodeAndCountry()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy<UKCompetentAuthority>();

            Address address = new Address(
                "1 High Street",
                null,
                "Some town",
                "Some county",
                "AABB",
                new Country(Guid.NewGuid(), "Netherlands"),
                "01234 567890",
                "*****@*****.**");

            Contact contact = new Contact("John", "Smith", "Manager");

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");
            organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, address);
            organisation.AddOrUpdateMainContactPerson(contact);

            Scheme scheme = new Scheme(organisation);
            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy<ObligationType>(),
                authority);

            int complianceYear = A.Dummy<int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy<Guid>(),
                A.Dummy<string>(),
                A.Dummy<List<MemberUploadError>>(),
                A.Dummy<decimal>(),
                complianceYear,
                scheme,
                A.Dummy<string>());

            memberUpload.Submit(A.Dummy<User>());

            List<MemberUpload> memberUploads = new List<MemberUpload>();
            memberUploads.Add(memberUpload);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy<User>());

            BySchemeCustomerFileGenerator generator = new BySchemeCustomerFileGenerator();

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);
            CustomerFile customerFile = result.IbisFile;

            // Assert
            Assert.NotNull(customerFile);
            Assert.Equal(1, customerFile.Customers.Count);

            Customer customer = customerFile.Customers[0];
            Assert.Equal("AABB  Netherlands", customer.Address.PostCode);
        }
Ejemplo n.º 15
0
 public void CreateContact(Contact contactToInsert)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 16
0
        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;
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Applies the behavior to a contact.
 /// </summary>
 /// <param name="contact">The contact.</param>
 public void ApplyTo(Contact contact)
 {
     _contactsToVisit.Add(contact);
     Trigger(contact);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ContactEventArgs"/> class.
 /// </summary>
 /// <param name="contact">The contact.</param>
 public AddContactEventArgs(Contact contact)
 {
     _contact = contact;
 }
Ejemplo n.º 19
0
 public void UpdateContact(Contact contactToUpdate)
 {
     throw new NotImplementedException();
 }