示例#1
0
        public static List <EventConferenceRoomRecord> UpdateEventConferenceRooms(
            IList <string> importConferenceRooms,
            IEventConferenceRoomService service
            )
        {
            var eventConferenceRoomRecords = service.FindAllAsync().Result;

            var patch = new PatchDefinition <string, EventConferenceRoomRecord>(
                (source, list) => list.SingleOrDefault(a => a.Name == source)
                );

            patch.Map(s => s, t => t.Name);
            var diff = patch.Patch(importConferenceRooms, eventConferenceRoomRecords);

            service.ApplyPatchOperationAsync(diff).Wait();

            return(diff.Where(a => a.Entity.IsDeleted == 0).Select(a => a.Entity).ToList());
        }
        private List <EventConferenceRoomRecord> UpdateEventConferenceRooms(
            IList <string> importConferenceRooms,
            ref int modifiedRecords
            )
        {
            var eventConferenceRoomRecords = _eventConferenceRoomService.FindAllAsync().Result;

            var patch = new PatchDefinition <string, EventConferenceRoomRecord>(
                (source, list) => list.SingleOrDefault(a => a.Name == source)
                );

            patch.Map(s => s, t => t.Name);
            var diff = patch.Patch(importConferenceRooms, eventConferenceRoomRecords);

            _eventConferenceRoomService.ApplyPatchOperationAsync(diff).Wait();

            modifiedRecords += diff.Count(a => a.Action != ActionEnum.NotModified);
            return(diff.Where(a => a.Entity.IsDeleted == 0).Select(a => a.Entity).ToList());
        }