public Response FunctionHandler(Request request) { var container = new CommandContainer(); container.RegisterRequirement <IDbConnection>(() => DbHelper.Connection) .Register <LogInCommand>(Operation.LogIn) .Register <ReadCommand>(Operation.Read) .Register <SignUpCommand>(Operation.SignUp) .Register <UpdateCommand>(Operation.Update) .Register <DeleteCommand>(Operation.Delete) .Register <VerifyEmailCommand>(Operation.VerifyEmail) .Register <VerifyUserCommand>(Operation.VerifyUser); try { request.Validate(); NotifyHelper.PushNotification($"{request.Operation} on UserService with payload {request.Payload.ToString()}."); return(container.Process(request)); } catch (Exception ex) { throw new LambdaException(HttpCode.BadRequest, ex.Message); } }
public void ContainerShouldWork() { var container = new CommandContainer(); container.RegisterRequirement <ICommand, TestCommand>() .Register <TestCommand2>(Operation.Create); var request = new Request() { Operation = Operation.Create }; Assert.Equal(typeof(TestCommand), container.Process(request).Payload.GetType()); }
public Response FunctionHandler(Request request) { var container = new CommandContainer(); container.RegisterRequirement <IDbConnection>(() => DbHelper.Connection) .Register <ReadCommand>(Operation.Read); try { request.Validate(); return(container.Process(request)); } catch (Exception ex) { throw new LambdaException(HttpCode.BadRequest, ex.Message); } }