/// <summary>
        /// The convert service area.
        /// </summary>
        /// <param name="areaId">
        /// The area id.
        /// </param>
        /// <param name="locationId">
        /// The location id.
        /// </param>
        /// <returns>
        /// The <see cref="ProviderCoverage"/>.
        /// </returns>
        private bool CreateServiceArea(int areaId, int locationId)
        {
            var coverage = new ProviderCoverage {
                LocationID = locationId, AreaID = areaId
            };

            var success = this.serviceProviderRepo.CreateCoverage(coverage);

            return(success);
        }
Esempio n. 2
0
        /// <summary>
        /// The create coverage.
        /// </summary>
        /// <param name="coverage">
        /// The coverage.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool CreateCoverage(ProviderCoverage coverage)
        {
            try
            {
                this.db.ProviderCoverages.Add(coverage);
                this.db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        /// <summary>
        /// The check coverage.
        /// </summary>
        /// <param name="coverage">
        /// The coverage.
        /// </param>
        /// <param name="locationId">
        /// The provider id.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool CheckCoverage(List <Coverage> coverage, int locationId)
        {
            var response = true;

            foreach (var coverage1 in coverage)
            {
                if (!response)
                {
                    return(false);
                }

                switch (coverage1.State)
                {
                case ObjectStatus.ObjectState.Create:
                    var newCoverare = new ProviderCoverage {
                        LocationID = locationId, AreaID = coverage1.CountyId
                    };
                    response = this.serviceProviderRepo.CreateCoverage(newCoverare);
                    break;

                case ObjectStatus.ObjectState.Update:
                    response = this.serviceProviderRepo.UpdateCoverage(locationId, coverage1);
                    break;

                case ObjectStatus.ObjectState.Delete:
                    response = this.serviceProviderRepo.DeleteCoverage(coverage1.Id);
                    break;

                case ObjectStatus.ObjectState.Read:
                    break;

                default:
                    response = false;
                    break;
                }
            }

            return(response);
        }
        public void MyTestInitialize()
        {
            this.target = new DatabaseToWebServiceProvider();

            this.contact = new Contact
            {
                Email    = "*****@*****.**",
                ID       = 1,
                Website  = "www.test.org",
                Phone    = "9373608284",
                HelpLine = "9373608888"
            };

            this.contactPerson = new ContactPerson
            {
                Contact   = this.contact,
                ContactID = 1,
                ID        = 1,
                FirstName = "Test",
                LastName  = "Person",
                JobTitle  = "Tester"
            };

            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.location1 = new Location
            {
                Name            = "Location1",
                CountryID       = 1,
                Country         = this.country,
                City            = "testville 1",
                ContactID       = 1,
                Contact         = this.contact,
                ContactPersonID = 1,
                ID                = 1,
                Display           = true,
                Zip               = "45344",
                Street            = "Test way 1",
                State             = this.state,
                StateID           = this.state.ID,
                ProviderCoverages = new List <ProviderCoverage> {
                    new ProviderCoverage {
                        County = new County {
                            Name = "County1"
                        }
                    }
                }
            };
            this.location2 = new Location
            {
                Name            = "Location2",
                CountryID       = 1,
                Country         = this.country,
                City            = "testville 2",
                ContactID       = 2,
                Contact         = this.contact,
                ContactPersonID = 2,
                ID                = 2,
                Display           = true,
                Zip               = "45344",
                Street            = "Test way 2",
                State             = this.state,
                StateID           = this.state.ID,
                ProviderCoverages = new List <ProviderCoverage> {
                    new ProviderCoverage {
                        County = new County {
                            Name = "County2"
                        }
                    }
                }
            };

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

            var providerService11 = new ProviderService {
                ID = 1, ProviderID = 1, ServiceID = 1, ProviderServiceCategory = new ProviderServiceCategory {
                    Name = "Category 1"
                }
            };
            var providerService12 = new ProviderService {
                ID = 2, ProviderID = 1, ServiceID = 2, ProviderServiceCategory = new ProviderServiceCategory {
                    Name = "Category 2"
                }
            };
            var providerService13 = new ProviderService {
                ID = 3, ProviderID = 1, ServiceID = 3, ProviderServiceCategory = new ProviderServiceCategory {
                    Name = "Category 3"
                }
            };

            var providerService21 = new ProviderService {
                ID = 1, ProviderID = 2, ServiceID = 1, ProviderServiceCategory = new ProviderServiceCategory {
                    Name = "Category 1"
                }
            };
            var providerService22 = new ProviderService {
                ID = 2, ProviderID = 2, ServiceID = 2, ProviderServiceCategory = new ProviderServiceCategory {
                    Name = "Category 2"
                }
            };
            var providerService23 = new ProviderService {
                ID = 3, ProviderID = 2, ServiceID = 3, ProviderServiceCategory = new ProviderServiceCategory {
                    Name = "Category 3"
                }
            };

            this.providerServices1 = new List <ProviderService>
            {
                providerService11,
                providerService12,
                providerService13,
            };

            this.providerServices2 = new List <ProviderService>
            {
                providerService21,
                providerService22,
                providerService23
            };

            this.serviceProvider1 = new ServiceProvider
            {
                Description      = "Test description for test 1",
                ID               = 1,
                DisplayRank      = 1,
                ProviderName     = "Test 1",
                Locations        = this.locations,
                ProviderServices = this.providerServices1,
                ServiceTypes     = 1,
                Active           = true,
                ServiceType      = new ServiceType {
                    Description = "Description", ID = 1, Name = "Name"
                }
            };
            this.serviceProvider2 = new ServiceProvider
            {
                Description      = "Test description for test 2",
                ID               = 2,
                DisplayRank      = 2,
                ProviderName     = "Test 2",
                Locations        = this.locations,
                ProviderServices = this.providerServices2,
                ServiceTypes     = 1,
                Active           = false,
                ServiceType      = new ServiceType {
                    Description = "Description", ID = 1, Name = "Name"
                }
            };

            this.serviceProviderList = new List <ServiceProvider> {
                this.serviceProvider1, this.serviceProvider2
            };

            this.providerCoverage1 = new ProviderCoverage {
                AreaID = 1, County = this.county, ID = 1, LocationID = 1
            };
            this.providerCoverage2 = new ProviderCoverage {
                AreaID = 1, County = this.county, ID = 2, LocationID = 2
            };

            this.providerCoverageList = new List <ProviderCoverage> {
                this.providerCoverage1, this.providerCoverage2
            };
        }