コード例 #1
0
        public IActionResult UpdateUser([FromBody] PutUser model)
        {
            if (ModelState.IsValid)
            {
                var userData = authService.GetCurrentUserData();


                var command = new UpdateUser(userData.UserId, model.FirstName, model.LastName);
                commandBus.AddCommand(command);
                commandBus.InvokeCommandsQueue();

                var result = GetUserDetails(userData.UserId);

                return(CreatedAtRoute(
                           "GetUser",
                           new { firstName = command.FirstName, lastName = command.LastName },
                           result
                           ));
            }

            return(BadRequest(ModelState));
        }
コード例 #2
0
        public IActionResult PutConsumptionReport(Guid vehicleId, Guid fuelReportId, [FromBody] PutFuelReport model)
        {
            if (ModelState.IsValid)
            {
                var userData = authService.GetCurrentUserData();
                var command  = new UpdateConsumptionReport(vehicleId, fuelReportId, userData.UserId, model.Distance, model.FuelBurned, model.PricePerUnit);
                commandBus.AddCommand(command);
                commandBus.InvokeCommandsQueue();

                return(GetConsumptionReport(vehicleId, fuelReportId));
            }

            return(BadRequest(ModelState));
        }