49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
|
using CloudBuilder.Core.Service;
|
|
using CloudBuilder.Security.Policy;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CloudBuilder.Master.Service
|
|
{
|
|
public class FileTypePolicyService : IFileTypePolicyService
|
|
{
|
|
private readonly IApplicationService service;
|
|
|
|
public FileTypePolicyService(IApplicationService service)
|
|
{
|
|
this.service = service;
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
[HttpPost]
|
|
public SelectOption[] FindSelectOption(bool blank)
|
|
{
|
|
FileTypePolicy policy = FileTypePolicy.GetInstance(service);
|
|
string[] values = policy.GetValues();
|
|
List<SelectOption> l = new List<SelectOption>();
|
|
|
|
SelectOption selectOption;
|
|
if (blank)
|
|
{
|
|
selectOption = new SelectOption();
|
|
l.Add(selectOption);
|
|
}
|
|
|
|
foreach (string value in values)
|
|
{
|
|
selectOption = new SelectOption();
|
|
selectOption.BindValue = value;
|
|
selectOption.DisplayName = policy.ComposeMessage(value, service.Locale);
|
|
l.Add(selectOption);
|
|
}
|
|
return l.ToArray();
|
|
}
|
|
}
|
|
}
|