Beispiel #1
0
        public WeightsModule(IWeightsService weightsService) : base("/weights/")
        {
            Get["/"] = _ => "Hello!";

            Post["/"] = _ =>
            {
                var newId       = weightsService.Create();
                var locationUri = ModulePath + newId;
                return(Negotiate
                       .WithModel(new { id = newId })
                       .WithHeader("Location", locationUri)
                       .WithStatusCode(HttpStatusCode.Created));
            };
        }
Beispiel #2
0
 public WeightsModule(IWeightsService weightsService)
     : base(RootUriStrings.Weights)
 {
     Post("/", async _ =>
     {
         //TODO: bind to CreateWeightRequestDto
         //TODO: validate DTO
         //TODO: map DTO -> BO
         var newWeightRequest = this.Bind <CreateWeightRequest>();
         var newId            = await weightsService.AddWeightAsync(newWeightRequest);
         return(Negotiate
                .WithModel(new { id = newId })
                .WithHeader("Location", RootUriStrings.Weights + newId)
                .WithStatusCode(HttpStatusCode.Created));
     });
 }
Beispiel #3
0
 public WeightsController(IWeightsService weightsService)
 {
     WeightsService = weightsService;
 }