Ejemplo n.º 1
0
        private BE.PlanillaBoleta UiToBe(BE.UI.PlanillaBoleta uiPlanillaBoleta)
        {
            var bePlanillaBoleta = new BE.PlanillaBoleta();

            bePlanillaBoleta.IdPlanillaBoleta = uiPlanillaBoleta.Id;

            //Obtener las propiedades que sean publicas y se puedan escribir
            var lstPropertiesInfosBE = bePlanillaBoleta.GetType().GetProperties()
                                       .Where(x => x.CanWrite == true && x.PropertyType.IsPublic == true)
                                       .ToList();

            //Obtener las propuedades que sean publicas y se puedan escribir
            var lstPropertiesInfosUI = uiPlanillaBoleta.GetType().GetProperties()
                                       .Where(x => x.PropertyType.IsPublic == true)
                                       .ToList();

            foreach (PropertyInfo propertyInfoBE in lstPropertiesInfosBE)
            {
                var propertyName = propertyInfoBE.Name;

                PropertyInfo propertyInfoUI = lstPropertiesInfosUI.Where(x => x.Name == propertyName).FirstOrDefault();
                if (propertyInfoUI != null)
                {
                    propertyInfoBE.SetValue(bePlanillaBoleta, propertyInfoUI.GetValue(uiPlanillaBoleta));
                }
            }

            return(bePlanillaBoleta);
        }