public override void RemoveRange(params T[] items)
        {
            var ids     = items.Select(n => n.ID).ToArray();
            var widgets = WidgetBasePartService.Get(m => ids.Contains(m.ID)).ToArray();

            WidgetBasePartService.RemoveRange(widgets);
        }
Esempio n. 2
0
        public override ServiceResult <T> Update(T item)
        {
            var basePart = WidgetBasePartService.Get(item.ID);

            item.CopyTo(basePart);
            WidgetBasePartService.Update(basePart);
            return(base.Update(item));
        }
Esempio n. 3
0
        public override IEnumerable <T> Get(Expression <Func <T, bool> > filter, Pagination pagination)
        {
            IEnumerable <WidgetBase> widgetBases = WidgetBasePartService.Get(Expression.Lambda <Func <WidgetBasePart, bool> >(filter.Body, filter.Parameters), pagination).Select(m => m.ToWidgetBase());

            foreach (var item in widgetBases)
            {
                yield return(item.CopyTo(JsonConvert.DeserializeObject <T>(item.ExtendData)) as T);
            }
        }
        public override ServiceResult <T> Update(T item)
        {
            item.ExtendData = JsonConvert.SerializeObject(item);
            var basePart = WidgetBasePartService.Get(item.ID);

            item.CopyTo(basePart);
            WidgetBasePartService.Update(basePart);
            return(new ServiceResult <T>());
        }
Esempio n. 5
0
        public override IEnumerable <T> Get()
        {
            IEnumerable <WidgetBase> widgetBases = WidgetBasePartService.Get().Select(m => m.ToWidgetBase());

            foreach (var item in widgetBases)
            {
                yield return(item.CopyTo(JsonConvert.DeserializeObject <T>(item.ExtendData)) as T);
            }
        }
Esempio n. 6
0
        public override T GetSingle(Expression <Func <T, bool> > filter)
        {
            T model = base.GetSingle(filter);

            if (typeof(T) != typeof(WidgetBase))
            {
                WidgetBasePartService.Get(model.ID).CopyTo(model);
            }
            return(model);
        }
Esempio n. 7
0
        public override IList <T> Get(Expression <Func <T, bool> > filter)
        {
            IEnumerable <WidgetBase> widgetBases = WidgetBasePartService.Get(Expression.Lambda <Func <WidgetBasePart, bool> >(filter.Body, filter.Parameters)).Select(m => m.ToWidgetBase());
            List <T> result = new List <T>();

            foreach (var item in widgetBases)
            {
                result.Add(item.CopyTo(JsonConvert.DeserializeObject <T>(item.ExtendData ?? "{}")) as T);
            }
            return(result);
        }
Esempio n. 8
0
        public override ServiceResult <T> Update(T item)
        {
            ServiceResult <T> result = null;

            BeginTransaction(() =>
            {
                var basePart = WidgetBasePartService.Get(item.ID);
                item.CopyTo(basePart);
                WidgetBasePartService.Update(basePart);
                result = base.Update(item);
            });
            return(result);
        }
Esempio n. 9
0
        public override IList <T> Get(Expression <Func <T, bool> > filter)
        {
            var widgets = base.Get(filter);

            if (widgets != null && typeof(T) != typeof(WidgetBase))
            {
                widgets.Each(widget =>
                {
                    WidgetBasePartService.Get(widget.ID).CopyTo(widget);
                });
            }
            return(widgets);
        }
Esempio n. 10
0
        public override ServiceResult <T> UpdateRange(params T[] items)
        {
            var ids       = items.Select(m => m.ID).ToArray();
            var baseParts = WidgetBasePartService.Get(m => ids.Contains(m.ID));

            foreach (var item in items)
            {
                item.CopyTo(baseParts.FirstOrDefault(m => m.ID == item.ID));
            }
            WidgetBasePartService.UpdateRange(baseParts.ToArray());

            return(base.UpdateRange(items));
        }
Esempio n. 11
0
        public override T Get(params object[] primaryKeys)
        {
            T model = base.Get(primaryKeys);

            if (model != null)
            {
                WidgetBasePartService.Get(primaryKeys).CopyTo(model);
            }
            if (model == null)
            {
                throw new Exception("Get widget error. Widget ID:" + string.Join(",", primaryKeys));
            }
            return(model);
        }
        public override ServiceResult <T> UpdateRange(params T[] items)
        {
            foreach (var item in items)
            {
                item.ExtendData = JsonConvert.SerializeObject(item);
            }
            var ids       = items.Select(m => m.ID).ToArray();
            var baseParts = WidgetBasePartService.Get(m => ids.Contains(m.ID));

            foreach (var item in items)
            {
                item.CopyTo(baseParts.FirstOrDefault(m => m.ID == item.ID));
            }
            WidgetBasePartService.UpdateRange(baseParts.ToArray());
            return(new ServiceResult <T>());
        }
Esempio n. 13
0
        public override T Get(params object[] primaryKeys)
        {
            var item = WidgetBasePartService.Get(primaryKeys);

            return(item.CopyTo(JsonConvert.DeserializeObject <T>(item.ExtendData ?? "{}")) as T);
        }