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))); }
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()); } }
public void Handle(CreateStationCommand command) { _logger.LogInformation($"Station Command Handler is Handling the Create Command with Station {command.Name}"); _stationService.Create(command); }