mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Org API controller and supporting data access
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
using System;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class OrganizationCreateRequestModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public PlanType Plan { get; set; }
|
||||
// TODO: Billing info for paid plans.
|
||||
|
||||
public virtual Organization ToOrganization(Guid userId)
|
||||
{
|
||||
var organization = new Organization
|
||||
{
|
||||
UserId = userId,
|
||||
Name = Name,
|
||||
Plan = Plan
|
||||
};
|
||||
|
||||
return organization;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class OrganizationUpdateRequestModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public virtual Organization ToOrganization(Organization existingOrganization)
|
||||
{
|
||||
existingOrganization.Name = Name;
|
||||
return existingOrganization;
|
||||
}
|
||||
}
|
||||
}
|
28
src/Api/Models/Response/OrganizationResponseModel.cs
Normal file
28
src/Api/Models/Response/OrganizationResponseModel.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class OrganizationResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationResponseModel(Organization organization)
|
||||
: base("organization")
|
||||
{
|
||||
if(organization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organization));
|
||||
}
|
||||
|
||||
Id = organization.Id.ToString();
|
||||
Name = organization.Name;
|
||||
Plan = organization.Plan;
|
||||
MaxUsers = organization.MaxUsers;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public PlanType Plan { get; set; }
|
||||
public short MaxUsers { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user