2022-03-01 11:44:13 +00:00
|
|
|
|
namespace ASC.Web.Api.Controllers.Settings;
|
2022-03-01 10:58:02 +00:00
|
|
|
|
|
|
|
|
|
public class CustomSchemasController : BaseSettingsController
|
|
|
|
|
{
|
|
|
|
|
private readonly MessageService _messageService;
|
|
|
|
|
private readonly CustomNamingPeople _customNamingPeople;
|
|
|
|
|
private readonly TenantManager _tenantManager;
|
|
|
|
|
private readonly PermissionContext _permissionContext;
|
|
|
|
|
|
2022-03-02 08:08:59 +00:00
|
|
|
|
public CustomSchemasController(
|
|
|
|
|
MessageService messageService,
|
2022-03-01 10:58:02 +00:00
|
|
|
|
ApiContext apiContext,
|
|
|
|
|
TenantManager tenantManager,
|
|
|
|
|
PermissionContext permissionContext,
|
|
|
|
|
WebItemManager webItemManager,
|
|
|
|
|
CustomNamingPeople customNamingPeople,
|
|
|
|
|
IMemoryCache memoryCache) : base(apiContext, memoryCache, webItemManager)
|
2022-03-02 08:08:59 +00:00
|
|
|
|
{
|
|
|
|
|
_messageService = messageService;
|
2022-03-01 10:58:02 +00:00
|
|
|
|
_customNamingPeople = customNamingPeople;
|
|
|
|
|
_tenantManager = tenantManager;
|
|
|
|
|
_permissionContext = permissionContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Read("customschemas")]
|
2022-03-15 10:00:41 +00:00
|
|
|
|
public List<SchemaRequestsDto> PeopleSchemas()
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
return _customNamingPeople
|
|
|
|
|
.GetSchemas()
|
|
|
|
|
.Select(r =>
|
|
|
|
|
{
|
|
|
|
|
var names = _customNamingPeople.GetPeopleNames(r.Key);
|
|
|
|
|
|
2022-03-15 10:00:41 +00:00
|
|
|
|
return new SchemaRequestsDto
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
Id = names.Id,
|
|
|
|
|
Name = names.SchemaName,
|
|
|
|
|
UserCaption = names.UserCaption,
|
|
|
|
|
UsersCaption = names.UsersCaption,
|
|
|
|
|
GroupCaption = names.GroupCaption,
|
|
|
|
|
GroupsCaption = names.GroupsCaption,
|
|
|
|
|
UserPostCaption = names.UserPostCaption,
|
|
|
|
|
RegDateCaption = names.RegDateCaption,
|
|
|
|
|
GroupHeadCaption = names.GroupHeadCaption,
|
|
|
|
|
GuestCaption = names.GuestCaption,
|
|
|
|
|
GuestsCaption = names.GuestsCaption,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Create("customschemas")]
|
2022-03-15 10:56:22 +00:00
|
|
|
|
public SchemaRequestsDto SaveNamingSettings(SchemaRequestsDto inDto)
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
|
|
|
|
|
|
2022-03-15 10:56:22 +00:00
|
|
|
|
_customNamingPeople.SetPeopleNames(inDto.Id);
|
2022-03-01 10:58:02 +00:00
|
|
|
|
|
|
|
|
|
_tenantManager.SaveTenant(_tenantManager.GetCurrentTenant());
|
|
|
|
|
|
|
|
|
|
_messageService.Send(MessageAction.TeamTemplateChanged);
|
|
|
|
|
|
2022-03-15 10:56:22 +00:00
|
|
|
|
return PeopleSchema(inDto.Id);
|
2022-03-01 10:58:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Update("customschemas")]
|
2022-03-15 10:56:22 +00:00
|
|
|
|
public SchemaRequestsDto SaveCustomNamingSettings(SchemaRequestsDto inDto)
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
|
|
|
|
|
|
2022-03-15 10:56:22 +00:00
|
|
|
|
var usrCaption = (inDto.UserCaption ?? "").Trim();
|
|
|
|
|
var usrsCaption = (inDto.UsersCaption ?? "").Trim();
|
|
|
|
|
var grpCaption = (inDto.GroupCaption ?? "").Trim();
|
|
|
|
|
var grpsCaption = (inDto.GroupsCaption ?? "").Trim();
|
|
|
|
|
var usrStatusCaption = (inDto.UserPostCaption ?? "").Trim();
|
|
|
|
|
var regDateCaption = (inDto.RegDateCaption ?? "").Trim();
|
|
|
|
|
var grpHeadCaption = (inDto.GroupHeadCaption ?? "").Trim();
|
|
|
|
|
var guestCaption = (inDto.GuestCaption ?? "").Trim();
|
|
|
|
|
var guestsCaption = (inDto.GuestsCaption ?? "").Trim();
|
2022-03-01 10:58:02 +00:00
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(usrCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(usrsCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(grpCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(grpsCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(usrStatusCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(regDateCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(grpHeadCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(guestCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(guestsCaption))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(Resource.ErrorEmptyFields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var names = new PeopleNamesItem
|
|
|
|
|
{
|
|
|
|
|
Id = PeopleNamesItem.CustomID,
|
|
|
|
|
UserCaption = usrCaption.Substring(0, Math.Min(30, usrCaption.Length)),
|
|
|
|
|
UsersCaption = usrsCaption.Substring(0, Math.Min(30, usrsCaption.Length)),
|
|
|
|
|
GroupCaption = grpCaption.Substring(0, Math.Min(30, grpCaption.Length)),
|
|
|
|
|
GroupsCaption = grpsCaption.Substring(0, Math.Min(30, grpsCaption.Length)),
|
|
|
|
|
UserPostCaption = usrStatusCaption.Substring(0, Math.Min(30, usrStatusCaption.Length)),
|
|
|
|
|
RegDateCaption = regDateCaption.Substring(0, Math.Min(30, regDateCaption.Length)),
|
|
|
|
|
GroupHeadCaption = grpHeadCaption.Substring(0, Math.Min(30, grpHeadCaption.Length)),
|
|
|
|
|
GuestCaption = guestCaption.Substring(0, Math.Min(30, guestCaption.Length)),
|
|
|
|
|
GuestsCaption = guestsCaption.Substring(0, Math.Min(30, guestsCaption.Length)),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_customNamingPeople.SetPeopleNames(names);
|
|
|
|
|
|
|
|
|
|
_tenantManager.SaveTenant(_tenantManager.GetCurrentTenant());
|
|
|
|
|
|
|
|
|
|
_messageService.Send(MessageAction.TeamTemplateChanged);
|
|
|
|
|
|
|
|
|
|
return PeopleSchema(PeopleNamesItem.CustomID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Read("customschemas/{id}")]
|
2022-03-15 10:00:41 +00:00
|
|
|
|
public SchemaRequestsDto PeopleSchema(string id)
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
var names = _customNamingPeople.GetPeopleNames(id);
|
2022-03-15 10:00:41 +00:00
|
|
|
|
var schemaItem = new SchemaRequestsDto
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
Id = names.Id,
|
|
|
|
|
Name = names.SchemaName,
|
|
|
|
|
UserCaption = names.UserCaption,
|
|
|
|
|
UsersCaption = names.UsersCaption,
|
|
|
|
|
GroupCaption = names.GroupCaption,
|
|
|
|
|
GroupsCaption = names.GroupsCaption,
|
|
|
|
|
UserPostCaption = names.UserPostCaption,
|
|
|
|
|
RegDateCaption = names.RegDateCaption,
|
|
|
|
|
GroupHeadCaption = names.GroupHeadCaption,
|
|
|
|
|
GuestCaption = names.GuestCaption,
|
|
|
|
|
GuestsCaption = names.GuestsCaption,
|
|
|
|
|
};
|
|
|
|
|
return schemaItem;
|
|
|
|
|
}
|
|
|
|
|
}
|