Esempio n. 1
0
        public void TerritoryTypeReturnsPod()
        {
            const TerritoryType expectedTerritoryType = TerritoryType.Pod;

            Territory territory = new PodTerritory();

            Assert.AreEqual(expectedTerritoryType, territory.TerritoryType);
        }
Esempio n. 2
0
        private Core.Geo.Domain.Territory GetTerritory()
        {
            long territoryId;
            long parentTerritoryId;

            long.TryParse(Request.QueryString["tid"], out territoryId);
            long.TryParse(Request.QueryString["pid"], out parentTerritoryId);

            switch ((TerritoryType)(byte.Parse(TerritoryTypeDDL.SelectedValue)))
            {
            case TerritoryType.Franchisee:
                var franchiseeTerritory = new FranchiseeTerritory(territoryId)
                {
                    FranchiseeOwnerId = long.Parse(TerritoryFranchiseeOwnerDDL.SelectedValue)
                };
                if (parentTerritoryId != 0)
                {
                    franchiseeTerritory.ParentTerritoryId = parentTerritoryId;
                }
                return(franchiseeTerritory);

            case TerritoryType.HospitalPartner:
                var hospitalPartnerOwnerIds = new List <long>();
                foreach (ListItem item in TerritoryHospitalPartnerOwnersCBL.Items)
                {
                    if (item.Selected)
                    {
                        hospitalPartnerOwnerIds.Add(long.Parse(item.Value));
                    }
                }
                if (!hospitalPartnerOwnerIds.IsEmpty())
                {
                    var hospitalPartnerTerritory = new HospitalPartnerTerritory(territoryId)
                    {
                        HospitalPartnerOwnerIds = hospitalPartnerOwnerIds
                    };
                    if (parentTerritoryId != 0)
                    {
                        hospitalPartnerTerritory.ParentTerritoryId = parentTerritoryId;
                    }
                    return(hospitalPartnerTerritory);
                }
                MessageControl1.ShowErrorMessage("At least one hospital partner must be selected.");
                break;

            case TerritoryType.ReadingPhysician:
                var readingPhysicianTerritory = new ReadingPhysicianTerritory(territoryId);
                if (parentTerritoryId != 0)
                {
                    readingPhysicianTerritory.ParentTerritoryId = parentTerritoryId;
                }
                return(readingPhysicianTerritory);

            case TerritoryType.Advertiser:
                var advertiserTerritory = new AdvertiserTerritory(territoryId);
                if (parentTerritoryId != 0)
                {
                    advertiserTerritory.ParentTerritoryId = parentTerritoryId;
                }
                return(advertiserTerritory);

            case TerritoryType.Pod:
                var podTerritory = new PodTerritory(territoryId);
                if (parentTerritoryId != 0)
                {
                    podTerritory.ParentTerritoryId = parentTerritoryId;
                }
                var packageIds =
                    (from ListItem item in TerritoryPackageCBL.Items
                     where item.Selected
                     select Convert.ToInt64(item.Value)).ToList();
                podTerritory.PackageIds = packageIds;
                return(podTerritory);
            }
            return(null);
        }