2018-03-21 17:41:14 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
using Bit.Core.Repositories;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Bit.Admin.Models;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Bit.Core.Models.Table;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Admin.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
public class OrganizationsController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IOrganizationRepository _organizationRepository;
|
|
|
|
|
|
|
|
|
|
|
|
public OrganizationsController(IOrganizationRepository organizationRepository)
|
|
|
|
|
|
{
|
|
|
|
|
|
_organizationRepository = organizationRepository;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-21 21:58:14 -04:00
|
|
|
|
public async Task<IActionResult> Index(string name = null, string userEmail = null, bool? paid = null,
|
2018-03-21 17:41:14 -04:00
|
|
|
|
int page = 1, int count = 25)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(page < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
page = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(count < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
count = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var skip = (page - 1) * count;
|
2018-03-21 21:58:14 -04:00
|
|
|
|
var organizations = await _organizationRepository.SearchAsync(name, userEmail, paid, skip, count);
|
2018-03-21 17:41:14 -04:00
|
|
|
|
return View(new OrganizationsModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Items = organizations as List<Organization>,
|
|
|
|
|
|
Name = string.IsNullOrWhiteSpace(name) ? null : name,
|
|
|
|
|
|
UserEmail = string.IsNullOrWhiteSpace(userEmail) ? null : userEmail,
|
|
|
|
|
|
Paid = paid,
|
|
|
|
|
|
Page = page,
|
|
|
|
|
|
Count = count
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|