Exemplo n.º 1
0
        public async Task <CommonCreatedResponseDto> RecordPositionAsync(PositionRecordRequestDto position)
        {
            try
            {
                var entity         = _mapper.Map <PositionTransaction>(position);
                var isValidVehicle = _repositoryWraper.Vehicle
                                     .FindByCondition(x => x.DiviseId == entity.DiviseId && x.IsActive).Any();

                if (isValidVehicle)
                {
                    entity.TransactionDate = DateTime.Now;
                    _repositoryWraper.PositionTransaction.Create(entity);
                    await _repositoryWraper.SaveAsync();

                    return(new CommonCreatedResponseDto {
                        IsSuccess = true, Message = string.Empty
                    });
                }

                throw new ServiceCustomException("Divise not active or no vehicle found.");
            }
            catch (ServiceCustomException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                _loggerManager.LogError($"Error in file name VehiclePositonRecordService.cs on function RecordPosition : {ex}");
                throw ex;
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> RecordPosition([FromBody] PositionRecordRequestDto position)
        {
            var result = await _vehicleRecordService.RecordPositionAsync(position);

            return(Ok(result));
        }