Exemplo n.º 1
0
        public async Task <Concept> Update(Concept c)
        {
            logger.LogInformation("Updating Concept. Concept:{@Concept}", c);
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                try
                {
                    var grid = await cn.QueryMultipleAsync(
                        Sql.Update,
                        new
                    {
                        id                           = c.Id,
                        universalId                  = c.UniversalId?.ToString(),
                        parentId                     = c.ParentId,
                        rootId                       = c.RootId,
                        externalId                   = c.ExternalId,
                        externalParentId             = c.ExternalParentId,
                        isPatientCountAutoCalculated = c.IsPatientCountAutoCalculated,
                        isNumeric                    = c.IsNumeric,
                        isParent                     = c.IsParent,
                        isRoot                       = c.IsRoot,
                        isSpecializable              = c.IsSpecializable,
                        sqlSetId                     = c.SqlSetId,
                        sqlSetWhere                  = c.SqlSetWhere,
                        sqlFieldNumeric              = c.SqlFieldNumeric,
                        uiDisplayName                = c.UiDisplayName,
                        uiDisplayText                = c.UiDisplayText,
                        uiDisplaySubtext             = c.UiDisplaySubtext,
                        uiDisplayUnits               = c.UiDisplayUnits,
                        uiDisplayTooltip             = c.UiDisplayTooltip,
                        uiDisplayPatientCount        = c.UiDisplayPatientCount,
                        uiNumericDefaultText         = c.UiNumericDefaultText,
                        constraints                  = ConceptConstraintTable.From(c),
                        specializationGroups         = ConceptSpecializationGroupTable.From(c),
                        user                         = user.UUID
                    },
                        commandType : CommandType.StoredProcedure,
                        commandTimeout : opts.DefaultTimeout
                        );

                    return(AdminConceptReader.Read(grid));
                }
                catch (SqlException se)
                {
                    logger.LogError("Could not update concept. Concept:{@Concept} Code:{Code} Error:{Error}", c, se.ErrorCode, se.Message);
                    se.MapThrow();
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        public async Task <Concept> Get(Guid id)
        {
            logger.LogInformation("Getting Concept. Id:{Id}", id);
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    Sql.Get,
                    new { id },
                    commandType : CommandType.StoredProcedure,
                    commandTimeout : opts.DefaultTimeout
                    );

                return(AdminConceptReader.Read(grid));
            }
        }