Exemple #1
0
        public async Task <CustomerVehicle> UpdateCustomerVehicle(CustomerVehicle vehicle, Guid clientId)
        {
            var existing = await repo.FindById(vehicle.Id, clientId);

            if (existing == null)
            {
                throw new Exception("Vehicle cannot be found");
            }
            var result = await repo.Update(vehicle, clientId);

            return(result);
        }
        public ResponseDetailsBase UpdateVehicleStatus(PingVehicleModel pingVehicle)
        {
            try
            {
                if (pingVehicle == null || string.IsNullOrEmpty(pingVehicle.VehicleId))
                {
                    return(new ResponseDetailsBase(ResponseStatusCode.InvalidInputs));
                }

                var vehicle = _customerVehicleRepository.DbSet.FirstOrDefault(v => v.VehicleId.ToLowerInvariant() == pingVehicle.VehicleId.ToLowerInvariant());
                if (vehicle == null)
                {
                    return(new ResponseDetailsBase(ResponseStatusCode.NotFound));
                }

                vehicle.LastPingTime = pingVehicle.CreatedAt;
                vehicle.UpdatedOn    = DateTime.UtcNow;
                _customerVehicleRepository.Update(vehicle);
                _customerVehicleRepository.Save();
                return(new ResponseDetailsList <CustomerVehicleAggregate>(ResponseStatusCode.Success));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message, null);
                return(new ResponseDetailsBase(ex));
            }
        }