public ChecklistHistory Map(ChecklistHistory history, ChecklistCategory category, ChecklistItem item) { if (!_historyCache.TryGetValue(history.ID, out ChecklistHistory result)) { history.Categories = new List <ChecklistCategory>(); _historyCache[history.ID] = history; result = history; } if ((category?.ID ?? 0L) != 0) { if (!_categoryCache.TryGetValue(category.ID, out ChecklistCategory categoryCache)) { category.Items = new List <ChecklistItem>(); _categoryCache[category.ID] = category; categoryCache = category; result.Categories.Add(category); } if ((item?.ID ?? 0L) != 0L) { categoryCache.Items.Add(item); } } return(result); }
public async Task <bool> UpdateChecklist(ChecklistHistory data) { return(await _requestProvider.BuildUpon(_url) .Uri($"/api/checklist") .Method(HttpMethod.Put) .AddInterceptor(new JsonDeserializerInterceptor()) .Content(new JsonContent(data)) .Execute <bool>()); }
public async Task <bool> InsertChecklist(ChecklistHistory checklist) { var checklistHistoryParam = new DynamicParameters(); checklistHistoryParam.Add("@Scheme", checklist.Scheme); checklistHistoryParam.Add("@Version", checklist.Version); checklistHistoryParam.Add("@CreatedBy", checklist.CreatedBy); checklistHistoryParam.Add("@EffectiveFrom", checklist.EffectiveFrom); checklistHistoryParam.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertChecklistHistory", checklistHistoryParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); checklist.ID = checklistHistoryParam.Get <long>("@ID"); //Insert checklist category foreach (var checklistCategory in checklist.Categories) { var checklistCategoryParam = new DynamicParameters(); checklistCategoryParam.Add("@Index", checklistCategory.Index); checklistCategoryParam.Add("@Text", checklistCategory.Text); checklistCategoryParam.Add("@HistoryID", checklist.ID); checklistCategoryParam.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertChecklistCategory", checklistCategoryParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); checklistCategory.ID = checklistCategoryParam.Get <long>("@ID"); //Insert checklist items foreach (var checklistCategoryItem in checklistCategory.Items) { var checklistItemParam = new DynamicParameters(); checklistItemParam.Add("@Index", checklistCategoryItem.Index); checklistItemParam.Add("@Text", checklistCategoryItem.Text); checklistItemParam.Add("@CategoryID", checklistCategory.ID); checklistItemParam.Add("@Notes", checklistCategoryItem.Notes); checklistItemParam.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertChecklistItem", checklistItemParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); } } return(true); }
public async Task <bool> Put([FromBody] ChecklistHistory checklist) { return(await _checklistService.UpdateChecklist(checklist)); }
public async Task <bool> Post([FromBody] ChecklistHistory checklist) { return(await _checklistService.InsertChecklist(checklist)); }
public async Task <bool> Update([FromBody] ChecklistHistory data) { var result = await _checklistService.UpdateChecklist(data); return(result); }
public async Task <bool> UpdateChecklist(ChecklistHistory data) { return(await _apiClient.ChecklistSdk.UpdateChecklist(data)); }
public async Task <bool> InsertChecklist(ChecklistHistory data) { return(await _apiClient.ChecklistSdk.InsertChecklist(data)); }
public InsertChecklistCommand(ChecklistHistory checklist) { _checklist = checklist; }
public async Task <bool> UpdateChecklist(ChecklistHistory checklist) { return(await Execute(new UpdateChecklistCommand(checklist))); }
public async Task <bool> InsertChecklist(ChecklistHistory checklist) { return(await Execute(new InsertChecklistCommand(checklist))); }
public UpdateChecklistCommand(ChecklistHistory checklist) { _checklist = checklist; }