private HttpMethods GetHttpMethod(HttpMethods httpMethod) { if (parser.Method == Methods.None) { return(httpMethod); } else { if (parser.Method == Methods.Put) { return(HttpMethods.Put); } else if (parser.Method == Methods.Delete) { return(HttpMethods.Delete); } } return(HttpMethods.None); }
private RestMethod GetRestMethod(HttpMethods method) { switch (parser.BaseAction) { case BaseActions.Version: if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetServerVersion, RestAuths.None)); } break; case BaseActions.Role: if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetRole, RestAuths.Admin)); } break; case BaseActions.Options: if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetServerOptions, RestAuths.Super)); } if (method == HttpMethods.Put) { return(new RestMethod(RestMethods.PutServerOptions, RestAuths.Super)); } if (method == HttpMethods.Post) { return(new RestMethod(RestMethods.ValidateServerOptions, RestAuths.Super)); } break; case BaseActions.Accounts: switch (parser.AccountAction) { case AccountActions.None: if (parser.DomainName.IsInvalid) { if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetAccountsForSuper, RestAuths.Super)); } if (method == HttpMethods.Post) { return(new RestMethod(RestMethods.PostAccount, RestAuths.Super)); } } else { if (method == HttpMethods.Put) { return(new RestMethod(RestMethods.PutAccount, RestAuths.Admin)); } if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetAccount, RestAuths.Admin)); } if (method == HttpMethods.Delete) { return(new RestMethod(RestMethods.DeleteAccount, RestAuths.Admin)); } } break; case AccountActions.Userz: if (parser.UsersId.IsInvalid) { if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetUserz, RestAuths.Admin)); } } else { int usersIndex = userz.GetIndex(parser.UsersId.ToString()); if (usersIndex >= 0) { if (parser.Username.IsInvalid) { if (method == HttpMethods.Get) { return(new RestMethod(RestMethods.GetUsers, RestAuths.Admin, usersIndex)); } if (method == HttpMethods.Post) { return(new RestMethod(RestMethods.PostUser, RestAuths.Admin, usersIndex)); } } else { if (method == HttpMethods.Put) { return(new RestMethod(RestMethods.PutUser, RestAuths.Admin, usersIndex)); } if (method == HttpMethods.Delete) { return(new RestMethod(RestMethods.DeleteUser, RestAuths.Admin, usersIndex)); } } } } break; } break; } return(new RestMethod()); }