public async Task <IActionResult> Delete([FromBody] Product request) { try { var resp = await _dataService.Delete(request); return(new OkObjectResult(resp)); } catch (Exception e) { Console.WriteLine("error create Product " + e); return(new OkObjectResult(null)); } }
public IActionResult Delete(string conditionCode) { try { //args check if (string.IsNullOrEmpty(conditionCode)) { return(JsonResultModel.Error($"Parameter invalid:conditionCode = null")); } //argumentsDic generate Dictionary <string, object> argumentsDic = new Dictionary <string, object>(); foreach (var item in Request.Query) { if (!argumentsDic.ContainsKey(item.Key)) { argumentsDic.Add(item.Key.ToUpperInvariant(), item.Value); } } //get filter var searchCondition = searchConditionService.GetByCode(conditionCode); if (searchCondition == null) { return(JsonResultModel.Error($"SearchCondition not found by conditionCode[{searchCondition}]")); } var filter = conditionAggregationService.AnalysisConditionToFilterDefinitionByConditionId(searchCondition.MetaObjectId, searchCondition.Id, argumentsDic); //delete before filter = triggerScriptEngineService.UpdateBefore(searchCondition.MetaObjectId, searchCondition.Code, filter); //delete dataAccessService.Delete(searchCondition.MetaObjectId, filter); return(JsonResultModel.Success("success")); } catch (Exception ex) { return(JsonResultModel.Error(ex.ToString())); } }
public IActionResult Delete([FromQuery] QueryArgs queryArgs) { try { //Pretreatment create queryContext QueryPiplineContext queryContext = PretreatmentAndCreateQueryPiplineContext(queryArgs); //缓存某个服务下的全部触发器脚本,包括before和after queryContext.TriggerScriptsOfOneServiceType = _triggerScriptService.GetTriggerScriptsUnDeletedByMetaObjectIdAndServiceType(queryContext.MetaObjectId, (int)ServiceType.Interface_Delete); //查询条件 FilterDefinition <BsonDocument> filter = conditionAggregationService.AnalysisConditionToFilterDefinitionByConditionId(queryContext, queryContext.ArgumentsDic); //trigger before filter = _triggerScriptService.RunTriggerScript(queryContext, TriggerPoint.Before, TriggerScriptService.FunctionName_MetaObject_Interface_Delete_Before, filter, CurrentApplicationContext, queryContext.InterfaceCode, filter); //queryResult var queryDatas = dataAccessService.GetList(queryContext.TenantId, queryContext.MetaObjectId, filter, null); //delete dataAccessService.Delete(queryContext.TenantId, queryContext.MetaObjectId, filter); //trigger after _triggerScriptService.RunTriggerScript(queryContext, TriggerPoint.After, TriggerScriptService.FunctionName_MetaObject_Interface_Delete_After, filter, CurrentApplicationContext, queryContext.InterfaceCode, queryDatas); return(JsonResultModel.Success("success")); } catch (ArgumentNullException argNullEx) { return(JsonResultModel.Error(argNullEx.Message)); } catch (ArgumentException argEx) { return(JsonResultModel.Error(argEx.Message)); } catch (Exception ex) { return(JsonResultModel.Error(ex.Message)); } }