init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
93
Kreta.WebApi/Naplo/Kreta.Naplo.Domain/ServiceContext.cs
Normal file
93
Kreta.WebApi/Naplo/Kreta.Naplo.Domain/ServiceContext.cs
Normal file
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Kreta.Naplo.Infrastructure;
|
||||
|
||||
namespace Kreta.Naplo.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Service contect
|
||||
/// </summary>
|
||||
public class ServiceContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Institute code
|
||||
/// </summary>
|
||||
public string InstituteCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// User identitier
|
||||
/// </summary>
|
||||
public int UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// User roles
|
||||
/// </summary>
|
||||
public IEnumerable<string> UserRoles { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Base url
|
||||
/// </summary>
|
||||
public string BaseUrl { get; }
|
||||
public int SchoolYearId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Api key
|
||||
/// </summary>
|
||||
public string ApiKey { get; }
|
||||
|
||||
/// <summary>
|
||||
/// User agent
|
||||
/// </summary>
|
||||
public string UserAgent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constuctor
|
||||
/// </summary>
|
||||
/// <param name="instituteCode">Institute code</param>
|
||||
/// <param name="userId">User Id</param>
|
||||
/// <param name="userRoles">User roles</param>
|
||||
/// <param name="baseUrl">Base url</param>
|
||||
/// <param name="apiKey">Api key</param>
|
||||
/// <param name="userAgent">User Agent</param>
|
||||
public ServiceContext(string instituteCode, int userId, IEnumerable<string> userRoles, string baseUrl, string apiKey, string userAgent, int schoolYearId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(instituteCode))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(InstituteCode)} cannot be null or white space");
|
||||
}
|
||||
|
||||
this.InstituteCode = instituteCode;
|
||||
|
||||
if (userId < Constants.MinimumPrimaryKeyValue)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(userId)} must be greater or equal than {Constants.MinimumPrimaryKeyValue}");
|
||||
}
|
||||
|
||||
if (schoolYearId < Constants.MinimumPrimaryKeyValue)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(schoolYearId)} must be greater or equal than {Constants.MinimumPrimaryKeyValue}");
|
||||
}
|
||||
this.SchoolYearId = schoolYearId;
|
||||
|
||||
this.UserId = userId;
|
||||
|
||||
this.UserRoles = userRoles ?? throw new ArgumentNullException(nameof(userRoles));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(baseUrl))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(baseUrl)} cannot be null or white space");
|
||||
}
|
||||
|
||||
this.BaseUrl = baseUrl;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(apiKey))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(apiKey)} cannot be null or white space");
|
||||
}
|
||||
|
||||
this.ApiKey = apiKey;
|
||||
|
||||
UserAgent = userAgent ?? throw new ArgumentNullException(nameof(userAgent));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue