Beispiel #1
0
        public async Task <ActionResult> Update(int id, [FromBody] StoppageRequestDto dto)
        {
            var validator = new StoppageValidator();
            var result    = await validator.ValidateAsync(dto);

            if (!result.IsValid)
            {
                return(BadRequest(result.Errors));
            }
            return(Ok(await _service.Update(id, dto)));
        }
Beispiel #2
0
        public async Task <Stoppage> Create(StoppageRequestDto dto)
        {
            Stoppage entity = _mapper.Map <StoppageRequestDto, Stoppage>(dto);

            entity.Station = await _unitOfWork._stationRepository.GetOneById(dto.StationId);

            entity.StationId = dto.StationId;

            Stoppage stoppage = await _unitOfWork._stoppageRepository.Create(entity);

            await _unitOfWork.SaveChanges();

            return(stoppage);
        }