예제 #1
0
        public ServiceModule(ProcessRepository processRepository)
        {
            Post["/Service/", true] = async(parameter, ct)
                                      =>
            {
                this.RequiresAuthentication();

                var currentUser = this.Context.CurrentUser as ProcessUserIdentity;
                if (currentUser == null)
                {
                    return(HttpStatusCode.BadRequest);
                }

                Context.Request.Body.Position = 0;
                string message;
                using (var sr = new StreamReader(Context.Request.Body))
                {
                    message = await sr.ReadToEndAsync().ConfigureAwait(false);
                }

                var jsonIsValid = JsonHelper.IsValid <Message>(message);
                if (jsonIsValid)
                {
                    await processRepository.StartProcess("MessageRouter",
                                                         new RawMessage { Id = Guid.NewGuid(), Timestamp = DateTime.UtcNow, Value = message },
                                                         currentUser.Id);
                }

                return(jsonIsValid ? HttpStatusCode.OK : HttpStatusCode.NotExtended);
            };
        }
예제 #2
0
 public UserValidator(ProcessRepository processRepository)
 {
     _processRepository = processRepository;
 }