/// <summary> /// 保存 /// </summary> /// <param name="data">要保存的数据</param> protected override async Task <IActivationRecord> ExecuteSaveAsync(TriggerCondition data) { var monthlyCondition = data as TriggerMonthlyCondition; if (monthlyCondition == null || monthlyCondition.Days.IsNullOrEmpty()) { return(null); } List <TriggerMonthlyConditionEntity> monthlyEntityList = new List <TriggerMonthlyConditionEntity>(); monthlyEntityList.AddRange(monthlyCondition.Days.Select(c => { var entity = c.MapTo <TriggerMonthlyConditionEntity>(); entity.TriggerId = data.TriggerId; return(entity); }).ToList()); var packageRecord = DefaultActivationRecord <TriggerMonthlyConditionEntity, ITriggerMonthlyConditionDataAccess> .CreatePackageRecord(); //移除当前的条件 IQuery removeQuery = QueryFactory.Create <TriggerMonthlyConditionQuery>(c => c.TriggerId == data.TriggerId); Remove(removeQuery); //添加新的条件 return(await SaveEntityAsync(monthlyEntityList.ToArray()).ConfigureAwait(false)); }
/// <summary> /// Remove data /// </summary> /// <param name="datas">Datas</param> /// <param name="activationOption">Activation option</param> /// <returns>Return the activation record</returns> public IActivationRecord Remove(IEnumerable <TEntity> datas, ActivationOption activationOption = null) { if (datas.IsNullOrEmpty()) { return(null); } var packageRecord = DefaultActivationRecord <TEntity, TDataAccess> .CreatePackageRecord(); foreach (var data in datas) { var dataRecord = Remove(data, activationOption); packageRecord.AddFollowRecords(dataRecord); } return(packageRecord); }
/// <summary> /// remove data /// </summary> /// <param name="datas">datas</param> /// <param name="activationOption">activation option</param> /// <returns></returns> public async Task <IActivationRecord> RemoveAsync(IEnumerable <ET> datas, ActivationOption activationOption = null) { if (datas.IsNullOrEmpty()) { return(null); } var packageRecord = DefaultActivationRecord <ET, DAI> .CreatePackageRecord(); foreach (var data in datas) { var dataRecord = await RemoveAsync(data, activationOption).ConfigureAwait(false); packageRecord.AddFollowRecords(dataRecord); } return(packageRecord); }
/// <summary> /// remove data /// </summary> /// <typeparam name="ET">entity</typeparam> /// <typeparam name="DAI">persistent data service</typeparam> /// <param name="datas">datas</param> /// <returns></returns> public async Task <IActivationRecord> RemoveAsync(params ET[] datas) { if (datas.IsNullOrEmpty()) { return(null); } await WarehouseManager.RemoveAsync(datas); var packageRecord = DefaultActivationRecord <ET, DAI> .CreatePackageRecord(); foreach (var data in datas) { var identityValue = data.GetIdentityValue(); packageRecord.AddFollowRecords(DefaultActivationRecord <ET, DAI> .CreateRemoveObjectRecord(identityValue)); } return(packageRecord); }