/// <summary>
        /// The create contact person.
        /// </summary>
        /// <param name="contactPerson">
        /// The contact person.
        /// </param>
        /// <param name="contactPersonContactId">
        /// The contact person contact id.
        /// </param>
        /// <returns>
        /// The <see cref="ContactPerson"/>.
        /// </returns>
        private int CreateContactPerson(ServiceProviderContactPerson contactPerson, int contactPersonContactId)
        {
            var databaseContact = new ContactPerson
            {
                ContactID = contactPersonContactId,
                FirstName = contactPerson.FistName,
                JobTitle  = contactPerson.JobTitle,
                LastName  = contactPerson.LastName
            };

            var id = this.serviceProviderRepo.CreateContactPerson(databaseContact);

            return(id);
        }
예제 #2
0
        /// <summary>
        /// The create service provider contact person.
        /// </summary>
        /// <param name="contactPerson">
        /// The contact person.
        /// </param>
        /// <returns>
        /// The <see cref="ServiceProviderContactPerson"/>.
        /// </returns>
        public ServiceProviderContactPerson CreateServiceProviderContactPerson(ContactPerson contactPerson)
        {
            if (contactPerson == null)
            {
                return(null);
            }

            var person = new ServiceProviderContactPerson
            {
                Id       = contactPerson.ID,
                FistName = contactPerson.FirstName,
                LastName = contactPerson.LastName,
                JobTitle = contactPerson.JobTitle,
                Contact  = this.CreateContact(contactPerson.Contact),
                State    = ObjectStatus.ObjectState.Read
            };

            return(person);
        }
예제 #3
0
        /// <summary>
        /// The update contact person.
        /// </summary>
        /// <param name="serviceProviderContactPerson">
        /// The service provider contact person.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool UpdateContactPerson(ServiceProviderContactPerson serviceProviderContactPerson)
        {
            try
            {
                var updatedContactPerson = this.db.ContactPersons.Single(u => u.ID == serviceProviderContactPerson.Id);

                updatedContactPerson.FirstName = serviceProviderContactPerson.FistName;
                updatedContactPerson.LastName  = serviceProviderContactPerson.LastName;
                updatedContactPerson.JobTitle  = serviceProviderContactPerson.JobTitle;

                this.db.Entry(updatedContactPerson).State = EntityState.Modified;
                this.db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// The delete contact person.
        /// </summary>
        /// <param name="contactPerson">
        /// The contact person.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool DeleteContactPerson(ServiceProviderContactPerson contactPerson)
        {
            try
            {
                var person = this.db.ContactPersons.Single(s => s.ID == contactPerson.Id);

                // Remove the foreign key.
                foreach (var location in person.Locations)
                {
                    location.ContactPersonID = null;
                }

                db.SaveChanges();

                this.db.ContactPersons.Remove(person);
                this.db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        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
            };
        }
 /// <summary>
 /// Checks if the contact person empty.
 /// </summary>
 /// <param name="contact"> The contact. </param>
 /// <returns> The <see cref="bool"/>. </returns>
 private bool IsContactPersonEmpty(ServiceProviderContactPerson contact)
 {
     return(string.IsNullOrEmpty(contact.FistName) &&
            string.IsNullOrEmpty(contact.LastName));
 }