Beispiel #1
0
        public AdminModule(ISessionProvider sessionProvider, IDispatchEvents eventDispatcher)
            : base(sessionProvider, eventDispatcher, "/api/admin")
        {
            Post["/clients/create"] = parameters =>
                {
                    var createCommand = this.Bind<CreateClientCommand>();

                    RavenSession.Advanced.UseOptimisticConcurrency = true;

                    var newClient = new Client
                        {
                            Name = createCommand.Name,
                        };

                    RavenSession.Store(newClient);
                    RavenSession.Store(new UniqueClientName
                        {
                            Id = createCommand.Name,
                        });

                    UncommitedEvents.Add(new ClientCreated
                        {
                            Id = newClient.Id,
                            Name = newClient.Name,
                        });

                    return HttpStatusCode.Processing;
                };

            Get["/clients/{clientId}"] = parameters =>
                {
                    var client = RavenSession.Load<Client>(string.Format("clients/{0}", parameters.clientId));
                    return Response.AsJson(new { client });
                };
        }
Beispiel #2
0
            public static IHaveServiceUnits Create(Client client)
            {
                var su = new ServiceUnits();

                if (client != null)
                {
                    if (client.EstimatedMinutesToService > 0)
                        su.EstimatedMinutesToService = client.EstimatedMinutesToService;

                    if (client.MinuteToServiceFactor != 0)
                        su.MinuteToServiceFactor = client.MinuteToServiceFactor;
                }

                return su;
            }