コード例 #1
0
        public async Task OnGetAsync(long?Id)
        {
            var configuration = new DataAccess.Models.Configuration();

            if (Id != null)
            {
                configuration = await dbContext.Configurations.Where(o => o.Id == Id).Include(x => x.ConfigurationDict).FirstOrDefaultAsync();

                if (configuration == null)
                {
                    Message = "There is no such configuration";
                }
                await SetPageModel(configuration);
            }
            else
            {
                Configuration = new ConfigurationVM();
                var userId       = User.GetLoggedInUserId <int>();
                var organization = await layoutService.GetOrganizationByUserId(userId);

                if (organization != null)
                {
                    Input = new InputModel()
                    {
                        OrganizationId = organization.Id
                    };
                }
                Organizations = new SelectList(await dbContext.Organizations.Select(x => x).ToListAsync(), nameof(DataAccess.Models.Organization.Id), nameof(DataAccess.Models.Organization.DisplayName));
            }
        }
コード例 #2
0
        private async Task SetPageModel(DataAccess.Models.Configuration configuration)
        {
            Organizations = new SelectList(await dbContext.Organizations.Select(x => x).ToListAsync(), nameof(DataAccess.Models.Organization.Id), nameof(DataAccess.Models.Organization.DisplayName));

            Configuration = new ConfigurationVM()
            {
                Id    = configuration.Id,
                Key   = configuration.ConfigurationDict.Key,
                Value = configuration.Value,
                Notes = configuration.Notes,
                ConfigurationDictId = configuration.ConfigurationDictId,
                OrganizationId      = configuration.OrganizationId
            };

            Input = new InputModel()
            {
                Id    = configuration.Id,
                Key   = configuration.ConfigurationDict.Key,
                Value = configuration.Value,
                Notes = configuration.Notes,
                ConfigurationDictId = configuration.ConfigurationDictId,
                OrganizationId      = configuration.OrganizationId
            };
        }