Ejemplo n.º 1
0
        public async Task <ActionResult> Create([FromBody] StationRequestDto dto)
        {
            var validator = new StationValidator();
            var result    = await validator.ValidateAsync(dto);

            if (!result.IsValid)
            {
                return(BadRequest(result.Errors));
            }
            return(Ok(await _service.Create(dto)));
        }
Ejemplo n.º 2
0
        public IActionResult Create(StationDto stationDto)
        {
            log.Info(nameof(StationController.Create) + " POST");

            try
            {
                if (ModelState.IsValid)
                {
                    stationService.Create(stationDto);

                    return(RedirectToAction(nameof(Index)));
                }

                ViewData["AreaId"] = new SelectList(areaService.GetAreas(), "Id", "Name", stationDto.AreaId);

                return(View(stationDto));
            }
            catch (Exception e)
            {
                log.Error(e);

                return(BadRequest());
            }
        }
Ejemplo n.º 3
0
 public void Handle(CreateStationCommand command)
 {
     _logger.LogInformation($"Station Command Handler is Handling the Create Command with Station {command.Name}");
     _stationService.Create(command);
 }