Innovenergy_trunk/csharp/app/API/Api.cs

66 lines
2.2 KiB
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
using Flurl;
using InnovEnergy.API.DataModel;
namespace InnovEnergy.API;
public static class Api
{
public static Result CreateUser(QueryParamCollection queryParams, LoginState loginState)
{
var parentPath = queryParams.FirstOrDefault("path") as String;
var userName = queryParams.FirstOrDefault("userName") as String;
var userType = queryParams.FirstOrDefault("userType") as String;
if (userName != null && Program.Data.Root.FindDescendantUser(userName) != null)
return Result.Failure("there is already another user with that name");
return loginState.CreateUser(parentPath, userName, userType);
}
public static Result EditUser(QueryParamCollection queryParams, LoginState loginState)
{
var userPath = queryParams.FirstOrDefault("path") as String;
var userType = queryParams.FirstOrDefault("userType") as String;
return loginState.EditUser(userPath, userType);
}
public static Result RenameInstallation(QueryParamCollection queryParams, LoginState loginState)
{
var userPath = queryParams.FirstOrDefault("path") as String;
var userType = queryParams.FirstOrDefault("name") as String;
return loginState.RenameInstallation(userPath, userType);
}
public static Result DeleteFolder(QueryParamCollection queryParams, LoginState loginState)
{
var path = queryParams.FirstOrDefault("path") as String;
return loginState.DeleteFolder(path);
}
public static Result DeleteInstallation(QueryParamCollection queryParams, LoginState loginState)
{
var path = queryParams.FirstOrDefault("path") as String;
return loginState.DeleteInstallation(path);
}
public static Result DeleteUser(QueryParamCollection queryParams, LoginState loginState)
{
var path = queryParams.FirstOrDefault("path") as String;
return loginState.DeleteUser(path);
}
// public static Result Rename(QueryParamCollection queryParams, LoginState loginState)
// {
// var path = queryParams.FirstOrDefault("path") as String;
// var name = queryParams.FirstOrDefault("name") as String;
//
// return loginState.Delete(path);
// }
}