/// <summary>
        /// The check contact for a contact with a required phone number
        /// </summary>
        /// <param name="contact"> The contact. </param>
        /// <returns> The <see cref="bool"/>. </returns>
        private bool CheckContact(ServiceProviderContactRequired contact)
        {
            bool response;

            switch (contact.State)
            {
            case ObjectStatus.ObjectState.Update:
                response = this.serviceProviderRepo.UpdateContact(this.ConvertServiceProviderContactToContact(contact));
                break;

            case ObjectStatus.ObjectState.Delete:
                response = this.serviceProviderRepo.DeleteContact(this.ConvertServiceProviderContactToContact(contact));
                break;

            case ObjectStatus.ObjectState.Read:
                response = true;
                break;

            default:
                response = false;
                break;
            }

            return(response);
        }
 /// <summary>
 /// The convert service provider contact to view model contact with required phone number.
 /// </summary>
 /// <param name="providerContact"> The provider contact. </param>
 /// <returns> The <see cref="Contact"/>. </returns>
 private Contact ConvertServiceProviderContactToContact(ServiceProviderContactRequired providerContact)
 {
     return(new Contact
     {
         ID = providerContact.Id,
         Email = providerContact.Email,
         Phone = providerContact.PhoneNumber,
         HelpLine = providerContact.HelpLine,
         Website = providerContact.Website
     });
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a view model contact with a required phone number from a database contact.
        /// </summary>
        /// <param name="contact"> The contact. </param>
        /// <returns> The <see cref="ServiceProviderContact"/>. </returns>
        private ServiceProviderContactRequired CreateLocationContact(Contact contact)
        {
            var webContact = new ServiceProviderContactRequired
            {
                Email       = contact.Email,
                HelpLine    = contact.HelpLine,
                PhoneNumber = contact.Phone,
                Id          = contact.ID,
                Website     = contact.Website,
                State       = ObjectStatus.ObjectState.Read
            };

            return(webContact);
        }
        public void MyTestInitialize()
        {
            this.target = new WebToDatabaseServiceProvider();

            this.state = new State {
                Abbreviation = "OH", CountryID = 1, FullName = "Ohio", ID = 1
            };
            this.country = new Country {
                Abbreviation = "USA", ID = 1, FullName = "United States of America"
            };
            this.county = new County {
                ID = 1, Name = "test county", StateId = 1, State = this.state
            };

            this.contact = new ServiceProviderContact
            {
                Email       = "*****@*****.**",
                Id          = 1,
                Website     = "www.test.org",
                PhoneNumber = "9373608284",
                HelpLine    = "9373608888",
                State       = ObjectStatus.ObjectState.Update
            };

            this.locationContact = new ServiceProviderContactRequired
            {
                Email       = "*****@*****.**",
                Id          = 1,
                Website     = "www.test.org",
                PhoneNumber = "9373608284",
                HelpLine    = "9373608888",
                State       = ObjectStatus.ObjectState.Update
            };

            this.contactPerson = new ServiceProviderContactPerson
            {
                Id       = 1,
                Contact  = this.contact,
                FistName = "test",
                LastName = "user",
                JobTitle = "Tester",
                State    = ObjectStatus.ObjectState.Update
            };
            this.coverage1 = new Coverage
            {
                CountryId   = 1,
                CountryName = "USA",
                CountyId    = 1,
                CountyName  = "Clark",
                Id          = 1,
                State       = ObjectStatus.ObjectState.Update,
                StateId     = 1,
                StateName   = "Ohio"
            };
            this.coverage2 = new Coverage
            {
                CountryId   = 1,
                CountryName = "USA",
                CountyId    = 2,
                CountyName  = "Clark 2",
                Id          = 1,
                State       = ObjectStatus.ObjectState.Update,
                StateId     = 1,
                StateName   = "Ohio"
            };
            this.coverageList = new List <Coverage> {
                this.coverage1, this.coverage2
            };

            this.location1 = new ServiceProviderLocation
            {
                Name          = "Location1",
                Coverage      = this.coverageList,
                CountryId     = 1,
                Contact       = this.locationContact,
                ContactPerson = this.contactPerson,
                City          = "testville 1",
                Id            = 1,
                Display       = true,
                Zip           = "45344",
                Street        = "Test way 1",
                StateId       = this.state.ID,
                State         = ObjectStatus.ObjectState.Update
            };
            this.location2 = new ServiceProviderLocation
            {
                Name      = "Location2",
                Coverage  = this.coverageList,
                CountryId = 1,
                Contact   = this.locationContact,
                City      = "testville 2",
                Id        = 2,
                Display   = true,
                Zip       = "45344",
                Street    = "Test way 2",
                StateId   = this.state.ID,
                State     = ObjectStatus.ObjectState.Update
            };

            this.locations = new List <ServiceProviderLocation> {
                this.location1, this.location2
            };

            this.webServiceAreas = new WebServiceAreas
            {
                ServiceAreas = new List <int> {
                    1, 2, 3
                },
                State = ObjectStatus.ObjectState.Update
            };

            this.websiteServiceProvider = new WebsiteServiceProvider
            {
                Locations   = this.locations,
                Services    = this.webServiceAreas,
                Description = "Test Web Provider",
                DisplayRank = 1,
                Id          = 1,
                Name        = "test provider 1",
                Type        = 1,
                IsActive    = true,
                State       = ObjectStatus.ObjectState.Update
            };
        }