MoonBoxController控制器代码

 public class MoonBoxController : Controller
    {
        private readonly IWebHostEnvironment _webHostEnvironment;
        private readonly IRepository<MoonBox, int> _moonboxRepository;
        private readonly IMoonBoxService _moonboxService;
        private readonly IRepository<Course, int> _courseRepository;
        private readonly IRepository<MoonBoxCourse, int> _moonboxcourseRepository;
        private readonly SignInManager<ApplicationUser> _signInManager;
        private readonly IDataProtector _protector;
        public MoonBoxController(IWebHostEnvironment webHostEnvironment,
            IRepository<MoonBox, int> moonboxRepository, 
            IMoonBoxService moonboxService,
            IDataProtectionProvider dataProtectionProvider,
            DataProtectionPurposeStrings dataProtectionPurposeStrings,
            IRepository<Course, int> courseRepository, 
            IRepository<MoonBoxCourse, int> moonboxcourseRepository, 
            SignInManager<ApplicationUser> signInManager)
        {
            _webHostEnvironment = webHostEnvironment;
            _moonboxRepository = moonboxRepository;
            _moonboxService = moonboxService;
            _protector = dataProtectionProvider.CreateProtector(
                         dataProtectionPurposeStrings.CourseIdRouteValue);
            _courseRepository = courseRepository;
            _moonboxcourseRepository = moonboxcourseRepository;
            _signInManager = signInManager;
        }
        public async Task<IActionResult> Index(GetMoonBoxInput input)
        {
            if (_signInManager.IsSignedIn(User))
            {
                input.UserName = User.Identity.Name;
                ViewBag.user = User.Identity.Name;
            }
            
            var models = await _moonboxService.GetPagedMoonBoxList(input);
            var dto = new MoonBoxListViewModel();
            dto.MoonBoxs = models;
            return View(dto);         
        }
}

  

  

posted @ 2021-02-20 10:23  thund  阅读(31)  评论(0)    收藏  举报