tsk-76: Added model and context for AccessLevel (#108)
* tsk-76: Added model and context for AccessLevel * Formatted code * AccessLevel migrations are working * minor formatting * tsk-#76: Saving AccessLevel when uploading song * tsk-#76: Added endpoints * tsk-#76: Warning fix * tsk-#76: Adding more controller code * Functionality to modify access levels is operational * Formatting * tsk-#76: Added functionality * tsk-#76: Formatting code * tsk-#76: Adding more code * tsk-#76: Formatting
This commit was merged in pull request #108.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Icarus.Models;
|
||||
|
||||
public class AccessLevel
|
||||
{
|
||||
#region Properties
|
||||
[Newtonsoft.Json.JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("level")]
|
||||
public string? Level { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("song_id")]
|
||||
public int SongId { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public static AccessLevel DefaultLevel()
|
||||
{
|
||||
return new AccessLevel
|
||||
{
|
||||
Level = "Public"
|
||||
};
|
||||
}
|
||||
|
||||
public static AccessLevel PrivateLevel()
|
||||
{
|
||||
return new AccessLevel
|
||||
{
|
||||
Level = "Private"
|
||||
};
|
||||
}
|
||||
|
||||
public static bool IsAccessLevelValid(string level)
|
||||
{
|
||||
if (level.Equals(DefaultLevel().Level))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (level.Equals(PrivateLevel().Level))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user