using Abp.AspNetCore.Mvc.Controllers;
using Abp.IdentityFramework;
using Microsoft.AspNetCore.Identity;
using MineTec.ProManager.CommonDto;
using MineTec.ProManager.Admin.Models.Common;

namespace MineTec.ProManager.Admin.Controllers
{
    public abstract class ProManagerControllerBase : AbpController
    {
        protected ProManagerControllerBase()
        {
            LocalizationSourceName = ProManagerCoreConsts.LocalizationSourceName;
        }

        protected void CheckErrors(IdentityResult identityResult)
        {
            identityResult.CheckErrors(LocalizationManager);
        }

        protected SPagedInput PagedViewModelMapToPagedInputDto<TViewModel, SPagedInput>(TViewModel viewModel)
           where SPagedInput : PagedInputDto
           where TViewModel : PagedViewModel
        {
            var input = ObjectMapper.Map<SPagedInput>(viewModel);
            input.MaxResultCount = viewModel.Limit;
            input.SkipCount = (viewModel.Page - 1) * viewModel.Limit;

            return input;
        }
    }
}
