/// <summary> /// 创建推荐类别 /// </summary> /// <param name="recommendType">推荐类别实体</param> /// <returns>创建成功返回true,失败返回false</returns> public bool CreateRecommendType(RecommendItemType recommendType) { RecommendItemType type = recommendItemTypeRepository.Get(recommendType.TypeId); if (type != null) { return(false); } //已修改 //这里不需要判断是否插入成功吗 recommendItemTypeRepository.Insert(recommendType); RecommendItemType recommendItemType = recommendItemTypeRepository.Get(recommendType.TypeId); //创建成功 if (recommendItemType != null) { EventBus <RecommendItemType> .Instance().OnAfter(recommendType, new CommonEventArgs(EventOperationType.Instance().Create())); return(true); } else { return(false); } }
/// <summary> /// 推荐类别 /// </summary> public static RecommendItemType New() { RecommendItemType recommendItemType = new RecommendItemType() { Name = string.Empty, Description = string.Empty, DateCreated = DateTime.UtcNow }; return(recommendItemType); }
/// <summary> /// 删除推荐类别 /// </summary> /// <param name="recommendTypeId">推荐类别Id</param> /// <returns>删除成功返回true,失败返回false</returns> public bool DeleteRecommendType(string recommendTypeId) { //设计要点 //1、需要删除:推荐内容; RecommendItemType recommendType = recommendItemTypeRepository.Get(recommendTypeId); int result = recommendItemTypeRepository.Delete(recommendType); if (result > 0) { EventBus <RecommendItemType> .Instance().OnAfter(recommendType, new CommonEventArgs(EventOperationType.Instance().Delete())); return(true); } else { return(false); } }
/// <summary> /// 更新推荐类别 /// </summary> /// <param name="recommendType">推荐类别实体</param> /// <returns>更新成功返回true,失败返回false</returns> public void UpdateRecommendType(RecommendItemType recommendType) { recommendItemTypeRepository.Update(recommendType); EventBus<RecommendItemType>.Instance().OnAfter(recommendType, new CommonEventArgs(EventOperationType.Instance().Update())); }
/// <summary> /// 创建推荐类别 /// </summary> /// <param name="recommendType">推荐类别实体</param> /// <returns>创建成功返回true,失败返回false</returns> public bool CreateRecommendType(RecommendItemType recommendType) { RecommendItemType type = recommendItemTypeRepository.Get(recommendType.TypeId); if (type != null) return false; //已修改 //这里不需要判断是否插入成功吗 recommendItemTypeRepository.Insert(recommendType); RecommendItemType recommendItemType = recommendItemTypeRepository.Get(recommendType.TypeId); //创建成功 if (recommendItemType != null) { EventBus<RecommendItemType>.Instance().OnAfter(recommendType, new CommonEventArgs(EventOperationType.Instance().Create())); return true; } else { return false; } }
/// <summary> /// 推荐类别 /// </summary> public static RecommendItemType New() { RecommendItemType recommendItemType = new RecommendItemType() { Name = string.Empty, Description = string.Empty, DateCreated = DateTime.UtcNow }; return recommendItemType; }
/// <summary> /// 更新推荐类别 /// </summary> /// <param name="recommendType">推荐类别实体</param> /// <returns>更新成功返回true,失败返回false</returns> public void UpdateRecommendType(RecommendItemType recommendType) { recommendItemTypeRepository.Update(recommendType); EventBus <RecommendItemType> .Instance().OnAfter(recommendType, new CommonEventArgs(EventOperationType.Instance().Update())); }