public ActorsModule(IActorProvider actorProvider) { this.Get("/actors", async(req, res, routeData) => { var people = actorProvider.Get(); await res.AsJson(people); }); this.Get("/actors/{id:int}", async(req, res, routeData) => { var person = actorProvider.Get(routeData.As <int>("id")); await res.Negotiate(person); }); this.Put("/actors/{id:int}", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } //Update the user in your database res.StatusCode = 204; }); this.Post("/actors", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } //Save the user in your database res.StatusCode = 201; await res.Negotiate(result.Data); }); this.Get("/actors/download", async(request, response, routeData) => { using (var video = new FileStream("earth.mp4", FileMode.Open)) //24406813 { await response.FromStream(video, "video/mp4"); } }); }
public PrivateApiController( IActorProvider <SimulationActor> simulationActorProvider, ILogger <PublicApiController> logger) { this.simulationActorRef = simulationActorProvider.Get(); this.logger = logger; }
public EventProcessor( IActorProvider <ProcessingCoordinatorActor> processingCoordinatorActorProvider, IMapper mapper) { this.processingCoordinatorActor = processingCoordinatorActorProvider.Get(); this.mapper = mapper; }
public ActorsModule(IActorProvider actorProvider) { this.Get("/actors", async(req, res, routeData) => { var people = actorProvider.Get(); await res.AsJson(people); }); this.Get("/actors/{id:int}", async(req, res, routeData) => { var person = actorProvider.Get(routeData.AsInt("id")); await res.Negotiate(person); }); this.Put("/actors/{id:int}", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } //Update the user in your database res.StatusCode = 204; }); this.Post("/actors", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } //Save the user in your database res.StatusCode = 201; await res.Negotiate(result.Data); }); }
public PrivateApiController( IActorProvider <PrinterActor> printerActorProvider, ILogger <PrivateApiController> logger, IMapper mapper) { this.printerActorRef = printerActorProvider.Get(); this.logger = logger; this.mapper = mapper; }
public PublicApiController( IActorProvider <OrderActor> orderActorProvider, ILogger <PublicApiController> logger, IMapper mapper) { this.orderActorRef = orderActorProvider.Get(); this.logger = logger; this.mapper = mapper; }
public WarehouseSendActor( IActorProvider <HttpRequestActor> httpRequestActorProvider, IOptions <ServiceSettings> serviceSettings) { this.httpRequestActor = httpRequestActorProvider.Get(); this.serviceSettings = serviceSettings.Value; Receive <Models.WarehouseOrderModel>(Handle); }
public ExternalOrderProcessor( IActorProvider <HttpRequestActor> httpRequestActorProvider, IOptions <ServiceSettings> serviceSettings, IMapper mapper) { this.httpRequestActor = httpRequestActorProvider.Get(); this.serviceSettings = serviceSettings.Value; this.mapper = mapper; }
public ProcessingUnitActor( IActorProvider <HttpRequestActor> httpRequestActorProvider, IOptions <ServiceSettings> serviceSettings, IMapper mapper) { this.httpRequestActor = httpRequestActorProvider.Get(); this.serviceSettings = serviceSettings.Value; this.mapper = mapper; Receive <StartProcessing>(Handle); }
private PublicApiControllerSpec() { progOrderActor = Kit.CreateProgrammableActor <OrderActor>("order-actor"); IActorProvider <OrderActor> orderActorProvider = An <IActorProvider <OrderActor> >(); orderActorProvider.Get().Returns(progOrderActor.TestProbe); var config = new MapperConfiguration(cfg => cfg.AddProfile(new OrderMapping())); config.AssertConfigurationIsValid(); Subject = new PublicApiController( orderActorProvider, An <ILogger <PublicApiController> >(), config.CreateMapper()); }
private PrivateApiControllerSpec() { progProductActor = Kit.CreateProgrammableActor <ProductActor>("product-actor"); IActorProvider <ProductActor> productActorProvider = An <IActorProvider <ProductActor> >(); productActorProvider.Get().Returns(progProductActor.TestProbe); var config = new MapperConfiguration(cfg => cfg.AddProfile(new ProductMapping())); config.AssertConfigurationIsValid(); Subject = new PrivateApiController( productActorProvider, An <ILogger <PrivateApiController> >(), config.CreateMapper()); }
public ActorModule(IActorProvider actorProvider) { Get("/actors", (req, res) => { var actors = actorProvider.Get(); return(res.Negotiate(actors)); }); Get("/actors/{id:int}", (req, res) => { try { var actor = actorProvider.Get(req.RouteValues.As <int>("id")); return(res.Negotiate(actor)); } catch (KeyNotFoundException) { res.StatusCode = 404; return(Task.CompletedTask); } }); Post("/actors", async(req, res) => { var result = await req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } var actor = actorProvider.Create(result.Data); res.StatusCode = 201; await res.Negotiate(actor); }); Put("/actors/{id:int}", async(req, res) => { var result = await req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } result.Data.Id = req.RouteValues.As <int>("id"); actorProvider.Update(result.Data); res.StatusCode = 204; }); Post("/actors/{id:int}/avatar", async(req, res) => { try { var actor = actorProvider.Get(req.RouteValues.As <int>("id")); var file = await req.BindFile(); actor.Avatar = file.FileName; actorProvider.Update(actor); await res.Negotiate(actor); } catch (KeyNotFoundException) { res.StatusCode = 404; } }); Delete("/actors/{id:int}", (req, res) => { actorProvider.Delete(req.RouteValues.As <int>("id")); res.StatusCode = 204; return(Task.CompletedTask); }); }
public ActorsModule(IActorProvider actorProvider) { this.Get <GetActors>("/actors", (req, res, routeData) => { var people = actorProvider.Get(); return(res.AsJson(people)); }); this.Get <GetActorById>("/actors/{id:int}", (req, res, routeData) => { var person = actorProvider.Get(routeData.As <int>("id")); return(res.Negotiate(person)); }); this.Put <UpdateActor>("/actors/{id:int}", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } //Update the user in your database res.StatusCode = 204; }); this.Post <AddActor>("/actors", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } //Save the user in your database res.StatusCode = 201; await res.Negotiate(result.Data); }); this.Delete <DeleteActor>("/actors/{id:int}", (req, res, routeData) => { actorProvider.Delete(routeData.As <int>("id")); res.StatusCode = 204; return(Task.CompletedTask); }); this.Get("/actors/download", async(request, response, routeData) => { using (var video = new FileStream("earth.mp4", FileMode.Open)) //24406813 { await response.FromStream(video, "video/mp4"); } }); this.Get <EmptyOpenApiMetaData>("/empty", (request, response, routeData) => Task.CompletedTask); this.Get <SampleMetaData>("/actors/sample", (request, response, routeData) => Task.CompletedTask); this.Post <NoValidatorMetaData>("/actors/sample", (request, response, routeData) => Task.CompletedTask); }
public ActorsModule(IActorProvider actorProvider) { Get("/actors", async(req, res, routeData) => { var people = actorProvider.Get(); await res.Negotiate(people); }); Post("/actors", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } actorProvider.Add(result.Data); res.StatusCode = 201; await res.Negotiate(result.Data); }); Get("/actors/{id:int}", async(req, res, routeData) => { try { var person = actorProvider.Get(routeData.As <int>("id")); await res.Negotiate(person); } catch (InvalidOperationException) { res.StatusCode = 404; } }); Put("/actors/{id:int}", async(req, res, routeData) => { var result = req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } try { actorProvider.Update(result.Data); res.StatusCode = 204; } catch (InvalidOperationException) { res.StatusCode = 404; } }); Delete("/actors/{id:int}", (req, res, routeData) => { try { var actor = actorProvider.Get(routeData.As <int>("id")); actorProvider.Delete(actor); res.StatusCode = 204; } catch (InvalidOperationException) { res.StatusCode = 404; } return(Task.CompletedTask); }); }
public ActorModule(IActorProvider actorProvider) { this.Get <ListAllActors>("/actors", (req, res) => { var actors = actorProvider.Get(); return(res.Negotiate(actors)); }); Get <GetActorById>("/actors/{id:int}", (req, res) => { try { var actor = actorProvider.Get(req.RouteValues.As <int>("id")); return(res.Negotiate(actor)); } catch (KeyNotFoundException) { res.StatusCode = 404; return(Task.CompletedTask); } }); Post <CreateActor>("/actors", async(req, res) => { var result = await req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } var actor = actorProvider.Create(result.Data); res.StatusCode = 201; await res.Negotiate(actor); }); Put <UpdateActor>("/actors/{id:int}", async(req, res) => { var result = await req.BindAndValidate <Actor>(); if (!result.ValidationResult.IsValid) { res.StatusCode = 422; await res.Negotiate(result.ValidationResult.GetFormattedErrors()); return; } actorProvider.Update(result.Data); res.StatusCode = 204; }); Delete <DeleteActor>("/actors/{id:int}", (req, res) => { actorProvider.Delete(req.RouteValues.As <int>("id")); res.StatusCode = 204; return(Task.CompletedTask); }); }