Beispiel #1
0
        public List <Track> GetAllTracksByUserID(Guid userID)
        {
            var track  = new TracksRepository(settings.connectionString);
            var result = track.GetAllTracksByUserID(userID);

            return(result);
        }
Beispiel #2
0
        public Guid GetNextTrackID(Guid deviceID)
        {
            var track     = new TracksRepository(settings.connectionString);
            var nestTrack = track.GetNextTrackID(deviceID);

            return(nestTrack);
        }
Beispiel #3
0
        public async Task <ActionResult> RegisterTrackPost(RegisterTrackViewModel registerModel)
        {
            if (registerModel.Secret != null)
            {
                string userId = this.User.Identity.GetUserId();

                TracksRepository <Track> tracksRepo = new TracksRepository <Track>();
                IEnumerable <Track>      tracks     = tracksRepo.GetFor(registerModel.Secret);
                Track track = tracks.FirstOrDefault() as Track;
                if (track != null)
                {
                    EntityState state = await tracksRepo.RegisterUser(track.Id, userId);

                    if (state == EntityState.Modified)
                    {
                        return(RedirectToAction("Index", "Garage"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Sorry, something went wrong - please try again.");
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "That track secret was not found, try again.");
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #4
0
        public int SetStatusTrack(Guid DeviceID, Guid TrackID, int IsListen, string DateTimeListen)
        {
            // Получаем путь к треку
            var track     = new TracksRepository(settings.connectionString);
            var rowsCount = track.SetStatusTrack(DeviceID, TrackID, IsListen, DateTime.Parse(DateTimeListen));

            return(rowsCount);
        }
Beispiel #5
0
        public void RemoveTrack(int trackId)
        {
            TracksRepository tr = new TracksRepository();
            Track            t  = tr.GetTrack(trackId);

            if (t != null)
            {
                tr.RemoveTrack(t);
            }
        }
Beispiel #6
0
        public CourierHelperDb(string sqlServerConnectionString)
        {
            _context = new CourierHelperDbContext(sqlServerConnectionString);

            OrdersRepo       = new OrdersRepository(_context);
            CouriersRepo     = new CouriersRepository(_context);
            WarehousesRepo   = new WarehousesRepository(_context);
            CustomersRepo    = new CustomersRepository(_context);
            RoutesRepo       = new RoutesRepository(_context);
            ActivePointsRepo = new ActivePointsRepository(_context);
            TracksRepo       = new TracksRepository(_context);
        }
Beispiel #7
0
        public IActionResult GetTrackByID(Guid trackID)
        {
            // Получаем путь к треку
            var track = new TracksRepository(settings.connectionString);
            var path  = track.GetTrackPath(trackID);
            // Создаем поток из трека
            var stream = System.IO.File.OpenRead(path);

            Response.ContentLength = stream.Length;
            // Возвращаем поток audio/mpeg
            return(new FileStreamResult(stream, "audio/mpeg"));
        }
 public ObserveUseCase(TracksRepository _repository)
 {
     m_repository = _repository;
 }
Beispiel #9
0
        public async Task <HttpResponseMessage> PostLapTime(LapTimeDTO[] lapTimeDTOs)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            LapTimeDTO first = lapTimeDTOs.FirstOrDefault();

            if (first != null)
            {
                DriverResultsRepository <DriverResult> driverResultsRepo = new DriverResultsRepository <DriverResult>();
                CarsRepository <Car, CarDTO>           carsRepo          = new CarsRepository <Car, CarDTO>();
                TracksRepository <Track>             tracksRepo          = new TracksRepository <Track>();
                BestLapTimesRepository <BestLapTime> bestLapsRepo        = new BestLapTimesRepository <BestLapTime>();

                DriverResult driverResult = await driverResultsRepo.GetById(first.DriverResultId);

                BestLapTime usersBestLapInCar = bestLapsRepo.GetForUserId(driverResult.ApplicationUserId).Where(bl => bl.CarId == driverResult.CarId).FirstOrDefault();
                TimeSpan    fastestLap        = driverResult.BestLapTime;
                BestLapTime bestLapTime       = new BestLapTime();

                foreach (LapTimeDTO lapTimeDTO in lapTimeDTOs)
                {
                    LapTime lapTime = new LapTime()
                    {
                        Id             = Guid.NewGuid().ToString(),
                        DriverResultId = lapTimeDTO.DriverResultId,
                        LapNumber      = lapTimeDTO.LapNumber,
                        Time           = lapTimeDTO.Time
                    };

                    lapTime = await repo.Insert(lapTime);

                    if (lapTime.Time == fastestLap)
                    {
                        bestLapTime = new BestLapTime()
                        {
                            Id = Guid.NewGuid().ToString(),
                            ApplicationUserId = driverResult.ApplicationUserId,
                            CarId             = driverResult.CarId,
                            LapTimeId         = lapTime.Id,
                        };

                        if (usersBestLapInCar == null)
                        {
                            bestLapTime = await bestLapsRepo.Insert(bestLapTime);
                        }
                        else if (fastestLap < usersBestLapInCar.LapTime.Time)
                        {
                            EntityState response = await bestLapsRepo.Update(usersBestLapInCar.Id, bestLapTime);
                        }

                        Car car = await carsRepo.GetById(driverResult.CarId);

                        var carsBestLapTime = car?.BestLapTime?.LapTime?.Time;
                        if (car?.BestLapTimeId == null || fastestLap < carsBestLapTime)
                        {
                            car.BestLapTimeId = bestLapTime.Id;
                            await carsRepo.Update(car.Id, car);
                        }

                        Track track = await tracksRepo.GetById(car?.TrackId);

                        var trackBestLap = track?.BestLapTime?.LapTime?.Time;
                        if (track?.BestLapTimeId == null || fastestLap < trackBestLap)
                        {
                            track.BestLapTimeId = bestLapTime.Id;
                            await tracksRepo.Update(track.Id, track);
                        }
                    }
                }
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
 public UpdateUseCase(TracksRepository _repository)
 {
     m_repository = _repository;
 }
Beispiel #11
0
 public TracksController(TracksRepository repository)
 {
     _repository = repository;
 }