Пример #1
0
        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);
        }
Пример #2
0
 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>());
 }
Пример #3
0
        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);
        }
Пример #4
0
 public async Task <bool> Put([FromBody] ChecklistHistory checklist)
 {
     return(await _checklistService.UpdateChecklist(checklist));
 }
Пример #5
0
 public async Task <bool> Post([FromBody] ChecklistHistory checklist)
 {
     return(await _checklistService.InsertChecklist(checklist));
 }
Пример #6
0
        public async Task <bool> Update([FromBody] ChecklistHistory data)
        {
            var result = await _checklistService.UpdateChecklist(data);

            return(result);
        }
Пример #7
0
 public async Task <bool> UpdateChecklist(ChecklistHistory data)
 {
     return(await _apiClient.ChecklistSdk.UpdateChecklist(data));
 }
Пример #8
0
 public async Task <bool> InsertChecklist(ChecklistHistory data)
 {
     return(await _apiClient.ChecklistSdk.InsertChecklist(data));
 }
Пример #9
0
 public InsertChecklistCommand(ChecklistHistory checklist)
 {
     _checklist = checklist;
 }
Пример #10
0
 public async Task <bool> UpdateChecklist(ChecklistHistory checklist)
 {
     return(await Execute(new UpdateChecklistCommand(checklist)));
 }
Пример #11
0
 public async Task <bool> InsertChecklist(ChecklistHistory checklist)
 {
     return(await Execute(new InsertChecklistCommand(checklist)));
 }
Пример #12
0
 public UpdateChecklistCommand(ChecklistHistory checklist)
 {
     _checklist = checklist;
 }