-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple organisations in one database (#150)
Co-authored-by: Magnus Gule <mg@variant.no> Co-authored-by: Sigrid Elnan <sge@variant.no>
- Loading branch information
1 parent
679f163
commit 670a6d8
Showing
40 changed files
with
751 additions
and
2,242 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Database.DatabaseContext; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Api.Organisation; | ||
|
||
[Route("/v0/organisations")] | ||
[ApiController] | ||
public class OrganisationController : ControllerBase | ||
{ | ||
private readonly ApplicationContext _applicationContext; | ||
|
||
public OrganisationController(ApplicationContext applicationContext) | ||
{ | ||
_applicationContext = applicationContext; | ||
} | ||
|
||
[HttpGet] | ||
public ActionResult<List<OrganisationReadModel>> Get() | ||
{ | ||
return _applicationContext.Organization | ||
.Select(organization => new OrganisationReadModel(organization.Name, organization.UrlKey)) | ||
.ToList(); | ||
} | ||
|
||
|
||
[HttpGet] | ||
[Route("{orgUrlKey}/departments")] | ||
public ActionResult<List<DepartmentReadModel>> GetDepartment([FromRoute] string orgUrlKey) | ||
{ | ||
return _applicationContext.Organization | ||
.Include(o => o.Departments) | ||
.Single(o => o.UrlKey == orgUrlKey) | ||
.Departments | ||
.Select(d => new DepartmentReadModel(d.Id, d.Name)) | ||
.ToList(); | ||
} | ||
} | ||
|
||
public record DepartmentReadModel(string Id, string Name); | ||
|
||
public record OrganisationReadModel(string Name, string UrlKey); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Core.DomainModels; | ||
|
||
public class Organization | ||
{ | ||
public required string Id { get; set; } // guid ? Decide What to set here first => | ||
public required string Name { get; set; } | ||
public required string UrlKey { get; set; } // "variant-as", "variant-sverige" | ||
public required string Country { get; set; } | ||
public required int NumberOfVacationDaysInYear { get; set; } | ||
public required bool HasVacationInChristmas { get; set; } | ||
public required double HoursPerWorkday { get; set; } | ||
|
||
[JsonIgnore] public List<Department> Departments { get; set; } | ||
Check warning on line 15 in backend/Core/DomainModels/Organization.cs GitHub Actions / Build and deploy Backend
|
||
|
||
public required List<Customer> Customers { get; set; } | ||
|
||
public List<Absence> AbsenceTypes { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.