public override void UpdateWidget(WidgetBase widget) { base.UpdateWidget(widget); var item = widget as CarouselWidget; if (item.CarouselItems != null && item.CarouselItems.Any()) { _carouselItemService.BeginBulkSave(); item.CarouselItems.Each(m => { m.CarouselWidgetID = item.ID; if (m.ActionType == ActionType.Create) { _carouselItemService.Add(m); } else if (m.ActionType == ActionType.Delete) { _carouselItemService.Remove(m); } else { _carouselItemService.Update(m); } }); _carouselItemService.SaveChanges(); } }
private void SaveCarouselItems(CarouselItemEntity item) { switch (item.ActionType) { case ActionType.Create: { _carouselItemService.Add(item); break; } case ActionType.Update: { _carouselItemService.Update(item); break; } case ActionType.Delete: { if (item.ID > 0) { _carouselItemService.Remove(item); } break; } } }
public override void DeleteWidget(string widgetId) { _carouselItemService.Remove(m => m.CarouselWidgetID == widgetId); base.DeleteWidget(widgetId); }