Commit 4afdb609 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Product/483-organizations' into 'Sprint/2020-07'

Product/483 organizations

See merge request coscine/api/project!89
parents bf3d7e42 70047254
......@@ -35,7 +35,7 @@ namespace Coscine.Api.Project.Tests
protected readonly List<ResourceDiscipline> ResourceDisciplines = new List<ResourceDiscipline>();
protected Discipline Discipline { get; set; }
protected Institute Institute { get; set; }
protected string Organization { get; set; }
protected Visibility Visibility { get; set; }
protected License License { get; set; }
protected RDSResourceType RdsResourceType { get; set; }
......@@ -74,13 +74,7 @@ namespace Coscine.Api.Project.Tests
};
disciplineModel.Insert(Discipline);
InstituteModel instituteModel = new InstituteModel();
Institute = new Institute()
{
DisplayName = "TestInstitute",
IKZ = "022000"
};
instituteModel.Insert(Institute);
Organization = "https://www.rwth-aachen.de/22000";
VisibilityModel visibilityModel = new VisibilityModel();
Visibility = visibilityModel.GetWhere((visibility) => visibility.DisplayName == "Public");
......@@ -137,7 +131,7 @@ namespace Coscine.Api.Project.Tests
ProjectInstituteModel projectInstituteModel = new ProjectInstituteModel();
projectInstituteModel.Insert(new ProjectInstitute()
{
InstituteId = Institute.Id,
OrganizationUrl = Organization,
ProjectId = project.Id
});
......@@ -340,9 +334,6 @@ namespace Coscine.Api.Project.Tests
DisciplineModel disciplineModel = new DisciplineModel();
disciplineModel.Delete(Discipline);
InstituteModel instituteModel = new InstituteModel();
instituteModel.Delete(Institute);
LicenseModel licenseModel = new LicenseModel();
licenseModel.Delete(License);
......
......@@ -114,7 +114,7 @@ namespace Coscine.Api.Project.Tests
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new List<OrganizationObject>() { new OrganizationObject(Organization, Organization) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
var stream = ObjectFactory<ProjectObject>.SerializeToStream(newProjectObject);
......@@ -149,7 +149,7 @@ namespace Coscine.Api.Project.Tests
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new List<OrganizationObject>() { new OrganizationObject(Organization, Organization) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
var stream = ObjectFactory<ProjectObject>.SerializeToStream(newProjectObject);
......@@ -187,7 +187,7 @@ namespace Coscine.Api.Project.Tests
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new List<OrganizationObject>() { new OrganizationObject(Organization, Organization) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
var stream = ObjectFactory<ProjectObject>.SerializeToStream(newProjectObject);
......@@ -202,7 +202,7 @@ namespace Coscine.Api.Project.Tests
newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new List<OrganizationObject>() { new OrganizationObject(Organization, Organization) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
createdProjectObject.Id);
......@@ -234,7 +234,7 @@ namespace Coscine.Api.Project.Tests
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new List<OrganizationObject>() { new OrganizationObject(Organization, Organization) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
var stream = ObjectFactory<ProjectObject>.SerializeToStream(newProjectObject);
......@@ -246,7 +246,7 @@ namespace Coscine.Api.Project.Tests
ProjectObject newSubProjectObject = new ProjectObject(Guid.NewGuid(), "NewSubProject", "NewDisplayNameSub", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new List<OrganizationObject>() { new OrganizationObject(Organization, Organization) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
createdProjectObject.Id);
......
using Coscine.Database.Models;
using Coscine.Database.ReturnObjects;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace Coscine.Api.Project.Controllers
{
[Authorize]
public class InstituteController : Controller
{
private readonly InstituteModel _instituteModel;
public InstituteController()
{
_instituteModel = new InstituteModel();
}
[Route("[controller]")]
public IActionResult Index()
{
return Json(_instituteModel.GetAll()
.Select((institute) => new InstituteObject(institute.Id, institute.IKZ, institute.DisplayName)));
}
}
}
......@@ -153,8 +153,6 @@ namespace Coscine.Api.Project.Controllers
from jd in joinedD.DefaultIfEmpty()
join pi in db.ProjectInstitutes on p.Id equals pi.ProjectId into joinedPi
from jpi in joinedPi.DefaultIfEmpty()
join i in db.Institutes on jpi.InstituteId equals i.Id into joinedI
from ji in joinedI.DefaultIfEmpty()
where p.Deleted == false &&
((!showSubProjects && p.Id.NotIn(allSubProjectsList)) ||
......@@ -171,9 +169,7 @@ namespace Coscine.Api.Project.Controllers
jv.DisplayName.Contains(searchQuery) ||
jd.Url.Contains(searchQuery) ||
jd.DisplayNameDe.Contains(searchQuery) ||
jd.DisplayNameEn.Contains(searchQuery) ||
ji.DisplayName.Contains(searchQuery) ||
ji.IKZ.Contains(searchQuery))
jd.DisplayNameEn.Contains(searchQuery))
select new { p.Id, p.DisplayName }).OrderBy(element => element.DisplayName).Distinct();
return JToken.Parse(JsonConvert.SerializeObject(results));
......
......@@ -611,7 +611,6 @@
<Compile Include="Controllers\LicenseController.cs" />
<Compile Include="Controllers\SearchController.cs" />
<Compile Include="Controllers\VisibilityController.cs" />
<Compile Include="Controllers\InstituteController.cs" />
<Compile Include="Controllers\DisciplineController.cs" />
<Compile Include="Controllers\ProjectController.cs" />
<Compile Include="Controllers\RoleController.cs" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment