public ICommandStrategy <TResource> GetOrThrow(UnsafeMethod method) { if (!ContainsKey(method)) { throw new MethodNotAllowedException(method, typeof(TResource)); } return(this[method]); }
private async Task <IHttpActionResult> GetResultFromMethodFeedbackAsync(UnsafeMethod method, ResourceBody body) { IRestEndpoint endpoint = GetEndpoint(); if (!endpoint.EvaluatePreconditions(GetPreconditions())) { return(StatusCode(HttpStatusCode.PreconditionFailed)); } Feedback feedback = await endpoint.CommandAsync(method, body); return(GetResultFromFeedback(feedback)); }
public Task <Feedback> CommandAsync(UnsafeMethod method, ResourceBody body) { ICommandStrategy <IRestCollection> strategy = Context.Services.Strategies.ForCollections.GetOrThrow(method); return(strategy.ExecuteAsync(Collection, Context, body)); }
internal MethodNotAllowedException(UnsafeMethod method, Type resourceType) : base(ErrorStatus.MethodNotAllowed, GetMessage(method, resourceType)) { }
private static string GetMessage(UnsafeMethod method, Type resourceType) { string resourceTypeName = resourceType.Name.Replace("IRest", string.Empty).ToLower(); return("The " + method.ToString().ToUpper() + " method is not allowed on a " + resourceTypeName); }
public Task <Feedback> CommandAsync(UnsafeMethod method, ResourceBody body) { throw new NotImplementedException("Not implemented unsafe strategies on dictionaries yet."); // TODO could implement PUTs with multi updates ? }
public Task <Feedback> CommandAsync(UnsafeMethod method, ResourceBody body) { throw new MethodNotAllowedException("Only safe methods are allowed on the directory."); }