private double CalculateTimeUntilMidnight() { var warpedNowTime = _timeCalculator.GetCurrentWarpedTime(); TimeSpan timerInterval = new DateTime(warpedNowTime.Year, warpedNowTime.Month, warpedNowTime.Day, 23, 59, 59, 999) - warpedNowTime; double timerIntervalInMiliseconds = Math.Round(timerInterval.TotalSeconds * 1000 / timeWarpFactor); return(timerIntervalInMiliseconds); }
private void LogIn() { var loggedCourierId = _menuOptions.LogInUser(); if (loggedCourierId != 0) { _loggedCourierId = loggedCourierId; _loggedIn = true; CourierSetup(); _logInDate = _timeCalculator.GetCurrentWarpedTime(); } }
public async Task AddNewPackageAsync(Package newPackage) { newPackage.Number = Guid.NewGuid(); newPackage.DateOfAdding = _timeCalculator.GetCurrentWarpedTime(); newPackage.State = Package.PackageState.AwaitingAddingToPackingList; using (var context = _dbContextFactoryMethod()) { context.Users.Attach(newPackage.Sender); context.Users.Attach(newPackage.Receiver); context.Packages.Add(newPackage); await context.SaveChangesAsync(); } }
public void ExportCourierPackingListToJsonFile(List <Package> packagesForPackingList, int courierId) { string systemDrivePath = Path.GetPathRoot(Environment.SystemDirectory); string targetPath = $"{systemDrivePath}shipping_lists"; Directory.CreateDirectory(targetPath); var listGenerationDate = _timeCalculator.GetCurrentWarpedTime().ToString("yyyy-MM-dd"); string fileName = $"{courierId}_{listGenerationDate}.json"; string filePath = Path.Combine(targetPath, $"{fileName}"); AddPackingListInfo(courierId, fileName, targetPath, packagesForPackingList.Count); var jsonData = JsonConvert.SerializeObject(packagesForPackingList, Formatting.Indented); File.WriteAllText(filePath, jsonData); }
public void MarkPackageAsDelivered(List <Package> currentPackingList) { int userChoice = _ioHelper.GetIntFromUser("Choose package"); int score; if (userChoice <= 0 || userChoice > currentPackingList.Count) { Console.WriteLine("There is no package with that id"); return; } score = _packagesService.DeliverPackage(currentPackingList[userChoice - 1].Id, currentPackingList[userChoice - 1].EtaToReceiver, _timeCalculator.GetCurrentWarpedTime()); if (score == 0) { Console.WriteLine("You have already marked this package as delivered"); return; } Console.WriteLine($"Your score for delivering this package is: {score}"); }
private void GetCurrentDate() { Console.WriteLine($"Current real time: {_timeCalculator.GetCurrentRealTime()}"); Console.WriteLine($"Current warped time: {_timeCalculator.GetCurrentWarpedTime()}"); }