public void AddPointRule(PlatformPointGroupRuleDataObject dataObject) { if (DateTime.Compare(dataObject.StartDate, dataObject.EndDate) >= 0) { throw new CustomException(505, "开始日期大于等于结束日期"); } CheckValidate(dataObject.DetailRules); PlatformPointGroupRule pointGroupRule = AutoMapper.Mapper.Map <PlatformPointGroupRuleDataObject, PlatformPointGroupRule>(dataObject); if (!this.platformPointGroupRuleRepository.ValidatePointGroupRule(pointGroupRule)) { throw new CustomException(505, "不能重复添加"); } this.unitOfWorkRepository.PersistCreationOf(pointGroupRule); this.unitOfWork.Commit(); }
public void UpdatePointRule(PlatformPointGroupRuleDataObject dataObject) { if (DateTime.Compare(dataObject.StartDate, dataObject.EndDate) >= 0) { throw new CustomException(505, "开始日期大于等于结束日期"); } CheckValidate(dataObject.DetailRules); PlatformPointGroupRule pointGroupRule = this.platformPointGroupRuleRepository.FindAll(p => p.ID.Equals (dataObject.ID)).FirstOrDefault(); if (pointGroupRule == null) { throw new CustomException(505, "修改扣点规则不存在!"); } pointGroupRule.DetailRules.Clear(); AutoMapper.Mapper.Map <PlatformPointGroupRuleDataObject, PlatformPointGroupRule>(dataObject, pointGroupRule); this.unitOfWorkRepository.PersistUpdateOf(pointGroupRule); this.unitOfWork.Commit(); }