DocSpace-client/products/ASC.Calendar/Server/Controllers/CalendarController.cs
2020-02-21 15:33:51 +03:00

99 lines
2.8 KiB
C#

using System.Collections.Generic;
using ASC.Api.Core;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Core.Common.Settings;
using ASC.Core.Tenants;
using ASC.Core.Users;
using ASC.Data.Reassigns;
using ASC.FederatedLogin;
using ASC.MessagingSystem;
using ASC.Calendar.Models;
using ASC.Security.Cryptography;
using ASC.Web.Api.Routing;
using ASC.Web.Core;
using ASC.Web.Core.Users;
using ASC.Web.Studio.Core;
using ASC.Web.Studio.Core.Notify;
using ASC.Web.Studio.UserControls.Statistics;
using ASC.Web.Studio.Utility;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using SecurityContext = ASC.Core.SecurityContext;
using ASC.Calendar.Core;
using ASC.Calendar.Core.Dao;
using ASC.Calendar.BusinessObjects;
namespace ASC.Calendar.Controllers
{
[DefaultRoute]
[ApiController]
public class CalendarController : ControllerBase
{
public Tenant Tenant { get { return ApiContext.Tenant; } }
public ApiContext ApiContext { get; }
public UserManager UserManager { get; }
public DataProvider DataProvider { get; }
public ILog Log { get; }
public TimeZoneConverter TimeZoneConverter { get; }
public CalendarWrapperHelper CalendarWrapperHelper { get; }
public CalendarController(
ApiContext apiContext,
UserManager userManager,
TimeZoneConverter timeZoneConverter,
IOptionsMonitor<ILog> option,
DataProvider dataProvider,
CalendarWrapperHelper calendarWrapperHelper)
{
Log = option.Get("ASC.Api");
TimeZoneConverter = timeZoneConverter;
ApiContext = apiContext;
UserManager = userManager;
DataProvider = dataProvider;
CalendarWrapperHelper = calendarWrapperHelper
}
[Read("info")]
public Module GetModule()
{
var product = new CalendarProduct();
product.Init();
return new Module(product, true);
}
[Read("{calendarId}")]
public CalendarWrapper GetCalendarById(int calendarId)
{
var calendars = DataProvider.GetCalendarById(calendarId);
return (calendars != null ? CalendarWrapperHelper.Get(calendars) : null);
}
}
public static class CalendarControllerExtention
{
public static IServiceCollection AddCalendarController(this IServiceCollection services)
{
return services
.AddApiContextService()
.AddSecurityContextService()
.AddCalendarDbContextService()
.AddCalendarDataProviderService()
.AddCalendarWrapper();
}
}
}