Beispiel #1
0
 public DataPushService(IPaymentContext context, IXrmService xrmService, ILogger logger)
 {
     this.logger     = logger;
     this.context    = context;
     this.xrmService = xrmService;
     this.entityType = new List <Type>();
 }
        public static async Task DisassociateAsync <T>(this IXrmService xrmService, T model, List <string> navigationProperties)
        {
            var entity = ConvertToCrmEntity(model);

            foreach (var navigationProperty in navigationProperties)
            {
                await xrmService.DisassociateAsync(entity, navigationProperty);
            }
        }
        public static async Task <IReadOnlyList <T> > GetFilteredListAsync <T>(this IXrmService xrmService, string entityCollection, string filter, params string[] properties)
            where T : class, new()
        {
            var crmEntities = await xrmService.GetFilteredListAsync(entityCollection, filter, properties);

            var list             = new List <T>();
            var entityProperties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)
                                   .Where(p => p.CanWrite && p.CanRead)
                                   .ToArray();

            foreach (var crmEntity in crmEntities)
            {
                list.Add(ConvertToEntity <T>(crmEntity, entityProperties));
            }

            return(list);
        }
        public static async Task <T> GetAsync <T>(this IXrmService xrmService, Guid id, params string[] properties)
            where T : class, new()
        {
            var type      = typeof(T);
            var attribute = type.GetCustomAttribute <EntityLogicalName>();

            if (attribute == null)
            {
                throw new XrmException($"{type.Name} type is missing {nameof(EntityLogicalName)} attribute.");
            }

            var crmEntity = await xrmService.GetAsync(attribute.LogicalName, id, properties);

            var entityProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)
                                   .Where(p => p.CanWrite && p.CanRead)
                                   .ToArray();

            return(ConvertToEntity <T>(crmEntity, entityProperties));
        }
Beispiel #5
0
 public Functions(PaymentContext paymentContext, IXrmService xrmService, ILogger logger)
 {
     this.context    = paymentContext;          // Select/Update from SQL DB
     this.xrmService = xrmService;
     this.logger     = logger;
 }
 public PerformanceCalculation(PaymentContext dataContext, IXrmService xrmService, ILogger logger)
 {
     this.logger      = logger;
     this.dataContext = dataContext;
     this.xrmService  = xrmService;
 }
        public static async Task <Guid> CreateAsync <T>(this IXrmService xrmService, T model)
        {
            var entity = ConvertToCrmEntity(model);

            return(await xrmService.CreateAsync(entity));
        }
 public static async Task UpdateAsync <T>(this IXrmService xrmService, T model)
 {
     var entity = ConvertToCrmEntity(model);
     await xrmService.UpdateAsync(entity);
 }