Пример #1
0
        internal static void UpdateSalesPerson(this Mapper mapper, Sample.Business.SalesPerson source, SalesPerson target)
        {
            // Verify null args:
            if (Object.ReferenceEquals(source, null))
            {
                return;
            }
            else if (Object.ReferenceEquals(target, null))
            {
                throw new Max.Domain.Mapping.MappingException("No target provided to map SalesPerson on.");
            }

            // Perform base type mapping:
            mapper.UpdateEmployee(source, target);

            // Perform mapping of properties:
            target.SalesQuota    = source.SalesQuota;
            target.Bonus         = source.Bonus;
            target.CommissionPct = source.CommissionPct;
            target.SalesYTD      = source.SalesYTD;
            mapper.MapSalesPersonTerritorySalesYTDProperty(source, target);

            // Call partial AfterUpdate method:
            AfterUpdateSalesPerson(mapper, source, target);
        }
Пример #2
0
 public static SalesPerson MapToSalesPerson(this Mapper mapper, Sample.Business.SalesPerson source)
 {
     if (source == null)
     {
         return(null);
     }
     else
     {
         return(mapper.MapToSalesPerson(source, new SalesPerson()));
     }
 }
Пример #3
0
 static void MapSalesPersonTerritorySalesYTDProperty(this Mapper mapper, Sample.Business.SalesPerson source, SalesPerson target)
 {
     do
     {
         var item0 = source;
         var item1 = item0.Territory;
         if (item1 == null)
         {
             break;
         }
         var item2 = item1.SalesYTD;
         target.TerritorySalesYTD = item2;
     } while (false);
 }
Пример #4
0
        internal static SalesPerson MapToSalesPerson(this Mapper mapper, Sample.Business.SalesPerson source, SalesPerson target)
        {
            // Null maps to null:
            if (source == null)
            {
                return(null);
            }

            // Check if object already mapped (as in circular reference scenarios):
            object mappedTarget = mapper.GetMappedTarget(source);

            // If so, return mapped instance:
            if (Object.ReferenceEquals(mappedTarget, null) == false)
            {
                return((SalesPerson)mappedTarget);
            }

            // Else, register mapping and map target:
            mapper.RegisterMapping(source, target);
            mapper.UpdateSalesPerson(source, target);

            // Return mapped target:
            return(target);
        }
 static partial void AfterUpdateSalesPerson(this ReverseMapper mapper, SalesPerson source, Sample.Business.SalesPerson target);
        internal static void UpdateSalesPerson(this ReverseMapper mapper, SalesPerson source, Sample.Business.SalesPerson target)
        {
            // Verify null args:
            if (Object.ReferenceEquals(source, null))
            {
                return;
            }
            else if (Object.ReferenceEquals(target, null))
            {
                throw new Max.Domain.Mapping.MappingException("No target provided to map SalesPerson on.");
            }

            // Map source to target:
            mapper.UpdateEmployee(source, target);
            if (target.SalesQuota != source.SalesQuota)
            {
                target.SalesQuota = source.SalesQuota;
            }
            if (target.Bonus != source.Bonus)
            {
                target.Bonus = source.Bonus;
            }
            if (target.CommissionPct != source.CommissionPct)
            {
                target.CommissionPct = source.CommissionPct;
            }
            if (target.SalesYTD != source.SalesYTD)
            {
                target.SalesYTD = source.SalesYTD;
            }

            // Call partial AfterUpdate method:
            AfterUpdateSalesPerson(mapper, source, target);
        }
        public static Sample.Business.SalesPerson MapFromSalesPerson(this ReverseMapper mapper, SalesPerson source, Sample.Business.SalesPerson target)
        {
            // Null maps to null:
            if (source == null)
            {
                return(null);
            }

            // Check if object already mapped (as in circular reference scenarios):
            object mappedTarget = mapper.GetMappedTarget(source);

            if (Object.ReferenceEquals(mappedTarget, null) == false)
            {
                return((Sample.Business.SalesPerson)mappedTarget);
            }

            // Retrieve target object:
            if (target == null)
            {
                target = mapper.TryGetTarget <Sample.Business.SalesPerson>(source);
            }
            if (target == null)
            {
                throw new Max.Domain.Mapping.MappingException(String.Format("Cannot map {0} to an existing instance.", source.GetType().Name));
            }

            // Register mapping:
            mapper.RegisterMapping(source, target);

            // Perform mapping:
            if (mapper.CanUpdate(target))
            {
                mapper.UpdateSalesPerson(source, target);
            }

            // Return target:
            return(target);
        }