public List <Inmate> GetAll() { var users = new List <Inmate>(); var connection = new SqlConnection("Server=localhost;Database=ClinkedIn;Trusted_Connection=True;"); connection.Open(); var getAllUsersCommand = connection.CreateCommand(); getAllUsersCommand.CommandText = @"select username, password, releaseDate, age, id from [user]"; var reader = getAllUsersCommand.ExecuteReader(); while (reader.Read()) { var id = (int)reader["Id"]; var username = reader["username"].ToString(); var password = reader["password"].ToString(); var releaseDate = (DateTime)reader["releaseDate"]; var age = (int)reader["age"]; var user = new Inmate(username, password, releaseDate, age) { Id = id }; users.Add(user); } connection.Close(); return(users); }
public List <string> GetAllFriends(string inmateName) { var inmate = new Inmate(); inmate = _inmates.FirstOrDefault(clinker => clinker.Name == inmateName); return(inmate.MyFriends); }
protected virtual void Think(int x, Vector3 randomDir, Quaternion startRot, bool _moving) { if (waterMeter <= 30) { //Get Water if (DiceRoll(UnityEngine.Random.Range(0, 6))) { if (myTap == null) { ChooseTap(); } if (!waiting) { movePos = myTap.transform.position; } moving = true; gettingWater = true; print("GettingWater"); } if (DiceRoll(UnityEngine.Random.Range(0, 15)) && foodMeter <= 30 && happy <= 30) { //Kill Someone Inmate toKill = gm._inmates[UnityEngine.Random.Range(0, gm._inmates.Count)]; movePos = toKill.transform.position; moving = true; imMadGonKill = true; } } }
private void SpawnInmates() { int x = rnd.Next(0, numInmates); int z = 0; int y = 0; do { if (i == numInmatesPerGroup) { y++; z = 0; numInmatesPerGroup = numInmatesPerGroup + cachInmateNum; } Vector3 center = spawnPositions[y].transform.position; Vector3 pos = RandomCircle(center, 1, z); pos.y = 0; Quaternion rot = Quaternion.LookRotation(center - pos); if (i == x) { GameObject objIns = Instantiate(targetObj, pos, rot) as GameObject; target = objIns.GetComponent <Target>(); objIns.GetComponent <Target>().myType = AI.TypeOfAI.sketchyTarget; } else { Inmate inmateIns = Instantiate(inmate, pos, rot) as Inmate; _inmates.Add(inmateIns); inmateIns.RndNum = rnd.Next(0, 50); } i++; z++; } while (i <= numInmates); }
public async Task RegisterBannedCoinAsync() { using CancellationTokenSource timeoutCts = new(TimeSpan.FromMinutes(2)); var bannedOutPoint = BitcoinFactory.CreateOutPoint(); var httpClient = _apiApplicationFactory.WithWebHostBuilder(builder => builder.ConfigureServices(services => { var inmate = new Inmate(bannedOutPoint, Punishment.LongBanned, DateTimeOffset.UtcNow, uint256.One); services.AddScoped <Prison>(_ => new Prison(new[] { inmate })); })).CreateClient(); var apiClient = await _apiApplicationFactory.CreateArenaClientAsync(httpClient); var rounds = (await apiClient.GetStatusAsync(RoundStateRequest.Empty, timeoutCts.Token)).RoundStates; var round = rounds.First(x => x.CoinjoinState is ConstructionState); // If an output is not in the utxo dataset then it is not unspent, this // means that the output is spent or simply doesn't even exist. using var signingKey = new Key(); var ownershipProof = WabiSabiFactory.CreateOwnershipProof(signingKey, round.Id); var ex = await Assert.ThrowsAsync <WabiSabiProtocolException>(async() => await apiClient.RegisterInputAsync(round.Id, bannedOutPoint, ownershipProof, timeoutCts.Token)); Assert.Equal(WabiSabiProtocolErrorCode.InputLongBanned, ex.ErrorCode); var inputBannedData = Assert.IsType <InputBannedExceptionData>(ex.ExceptionData); Assert.True(inputBannedData.BannedUntil > DateTimeOffset.UtcNow); }
public async Task <Inmate> AddInmate(Inmate inmate) { var inmateToReturn = _unitOfWork.Repository <Inmate>().Add(inmate); await _unitOfWork.Complete(); return(inmateToReturn); }
public async Task NoPrisonSerializationAsync() { // Don't serialize when there's no change. var workDir = Common.GetWorkDir(); await IoHelpers.TryDeleteDirectoryAsync(workDir); // Create prison. CoordinatorParameters coordinatorParameters = new(workDir); using var w = new Warden(coordinatorParameters.UtxoWardenPeriod, coordinatorParameters.PrisonFilePath, coordinatorParameters.RuntimeCoordinatorConfig); await w.StartAsync(CancellationToken.None); var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), uint256.Zero); var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), uint256.Zero); w.Prison.Punish(i1); w.Prison.Punish(i2); // Wait until serializes. await w.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(7)); // Make sure it does not serialize again as there was no change. File.Delete(w.PrisonFilePath); await w.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(7)); Assert.False(File.Exists(w.PrisonFilePath)); await w.StopAsync(CancellationToken.None); }
public async Task ReleasesInmatesAsync() { var workDir = Common.GetWorkDir(); await IoHelpers.TryDeleteDirectoryAsync(workDir); // Create prison. CoordinatorParameters coordinatorParameters = new(workDir); coordinatorParameters.RuntimeCoordinatorConfig.ReleaseUtxoFromPrisonAfter = TimeSpan.FromMilliseconds(1); using var w = new Warden(coordinatorParameters.UtxoWardenPeriod, coordinatorParameters.PrisonFilePath, coordinatorParameters.RuntimeCoordinatorConfig); await w.StartAsync(CancellationToken.None); var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), uint256.Zero); var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), uint256.Zero); var p = w.Prison; p.Punish(i1); p.Punish(i2); Assert.NotEmpty(p.GetInmates()); // Wait until releases from prison. await w.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(7)); Assert.Empty(p.GetInmates()); await w.StopAsync(CancellationToken.None); }
private static void MapToolToCheckOutInViewModel(Tool tool, Inmate inmate, UnitOfWork db) { var shop = db.ShopsRepo.FindById(tool.ShopId); var checkToolOutIn = new CheckToolOutInViewModel { ToolNumber = tool.ToolNumber, ToolDescription = tool.Description, ShopName = shop.Name, InmateId = inmate.Id, Inmate = inmate, ToolId = tool.Id, ToolReturned = true }; // check if tool is checked out bool toolCheckedOut = db.ToolsIssuedRepo .Exists(ti => ti.ToolId == tool.Id && !ti.ToolReturned); // if already checked out, get inmate name and assign to property if (toolCheckedOut) { // get ToolIssued obj var toolIssued = db.ToolsIssuedRepo.Find(ti => ti.ToolId == tool.Id && !ti.ToolReturned); var checkedOutByInmate = db.InmatesRepo.FindById(toolIssued.ReceivedByInmateId); checkToolOutIn.Inmate = checkedOutByInmate; checkToolOutIn.InmateId = checkedOutByInmate?.Id ?? 0; checkToolOutIn.IsCheckedOut = true; checkToolOutIn.ToolIssuedId = toolIssued.Id; checkToolOutIn.ToolReturned = toolIssued.ToolReturned; } CheckOutInTools.Add(checkToolOutIn); }
private static void MapToolsToCheckOutInViewModel(IEnumerable <Tool> tools, Inmate inmate, UnitOfWork db) { foreach (var tool in tools) { MapToolToCheckOutInViewModel(tool, inmate, db); } }
public Inmate AddUser(string username, string password, DateTime releaseDate, int age) { using (var connection = new SqlConnection(ConnectionString)) { connection.Open(); var insertUserCommand = connection.CreateCommand(); insertUserCommand.CommandText = $@"Insert into [user](username, password, releaseDate, age) Output inserted.* Values(@username, @password, @releaseDate, @age)"; insertUserCommand.Parameters.AddWithValue("username", username); //username from our AddUser parameter. insertUserCommand.Parameters.AddWithValue("password", password); insertUserCommand.Parameters.AddWithValue("releaseDate", releaseDate); insertUserCommand.Parameters.AddWithValue("age", age); var reader = insertUserCommand.ExecuteReader(); if (reader.Read()) { var insertedUsername = reader["username"].ToString(); var insertedPassword = reader["password"].ToString(); var insertedReleaseDate = (DateTime)reader["releaseDate"]; var insertedAge = (int)reader["age"]; var insertedId = (int)reader["Id"]; var newUser = new Inmate(insertedUsername, insertedPassword, insertedReleaseDate, insertedAge) { Id = insertedId }; return(newUser); } } throw new System.Exception("No user found"); }
public void Consume(NewInmateArrived newInmateArrived) { var inmate = new Inmate() { FullName = newInmateArrived.FullName, Surname = newInmateArrived.LastName }; _documentSession.Store(inmate); var inmateRecord = new InmateRecord() { InmateId = inmate.Id, LocationId = newInmateArrived.LocationId, CliffNotes = new List <CliffNote>(), StickyNotes = new List <StickyNote>() }; _documentSession.Store(inmateRecord); var dossier = new Dossier() { InmateId = inmate.Id, FlagReasons = new List <Flag>(), IsFlagged = false, Warrants = new List <Warrant>() }; _documentSession.Store(dossier); AcceptInmateIfDone(); }
// Builds crew by adding to friend's list internal List <string> AddCrew(List <string> crew, string name) { var inmateBuildingCrew = new Inmate(); inmateBuildingCrew = _inmates.FirstOrDefault(inmate => inmate.Name == name); inmateBuildingCrew.MyFriends.AddRange(crew); return(inmateBuildingCrew.MyFriends.Distinct().ToList()); }
public IActionResult AddNewInmate(Inmate newInmate) { var inmateList = clink.GetAllInmates(); newInmate.Id = inmateList.Any() ? inmateList.Max(thisGuy => thisGuy.Id) + 1 : 1; clink.Add(newInmate); return(Ok(new { newInmate.Id })); }
public IActionResult AddInmate(Inmate newInmate) { if (ModelState.IsValid) { _context.Inmate.Add(newInmate); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public void AddNewInmateInStorage(Inmate inmate) { // does inmate have an id? if no, find the highest id and add 1 // if not, set the id to 1 (IE, the very first inmate) inmate.Id = _alcatraz.Any() ? _alcatraz.Max(i => i.Id) + 1 : 1; _alcatraz.Add(inmate); Console.WriteLine(inmate); }
private object SendPlayerToJail(BasePlayer player, string prisonName, int time) { object cellNum = FindEmptyCell(prisonName); if (cellNum != null) { string zoneID = jailData.prisons[prisonName].zoneID; object cellPos = FindSpawnPoint(prisonName, (int)cellNum); if (cellPos == null) { return("noPos"); } jailData.prisons[prisonName].freeCells[(int)cellNum] = true; double jailTime = -99999; if (time != -99999) { jailTime = time + GrabCurrentTime(); } Inmate inmate = new Inmate() { initialPos = player.transform.position, prisonName = prisonName, cellNumber = (int)cellNum, expireTime = jailTime }; jailData.Prisoners.Add(player.userID, inmate); SendMsg(player, lang.GetMessage("sentPrison", this, player.UserIDString)); timer.Once(5, () => { SaveInventory(player); ZoneManager.Call("AddPlayerToZoneKeepinlist", zoneID, player); player.inventory.Strip(); TeleportPlayerPosition(player, (Vector3)cellPos); jailTimerList.Add(player.userID, time); CreateJailTimer(player); SendMsg(player, lang.GetMessage("checkTime", this, player.UserIDString)); if (giveKit) { if (kitName == null || kitName == "") { return; } Kits?.Call("GiveKit", player, kitName); } }); SaveData(); return(true); } return("noCells"); }
public async Task <bool> UpdateInmate(Inmate inmateRequest) { var inmate = await _unitOfWork.Repository <Inmate>().FindByIdAsync(inmateRequest.Id); if (inmate == null) { return(false); } _mapper.Map(inmateRequest, inmate); return(await _unitOfWork.Complete() > 0); }
private Inmate CreateInmateObject(Shop assignedShop) { var newInmate = new Inmate { FirstName = textBoxFirstName.Text.Trim(), LastName = textBoxLastName.Text.Trim(), GDCNumber = textBoxGDC.Text.Trim(), AssignedShop = assignedShop, ShopId = assignedShop.Id }; return(newInmate); }
public static void MapInmateToViewModel(Inmate inmate) { // shop obj needed to get the shop index for the drop down menu var shop = Shops.SingleOrDefault(s => s.Id == inmate.ShopId); Inmates.Add(new InmateViewModel { Id = inmate.Id, FirstName = inmate.FirstName, LastName = inmate.LastName, GDCNumber = inmate.GDCNumber, ShopId = inmate.ShopId, ShopIndex = Shops.IndexOf(shop) }); }
public Inmate Update(Inmate updatedInmate, int id) { var inmateToUpdate = _inmates.First(inmate => inmate.id == id); inmateToUpdate.Name = updatedInmate.Name; inmateToUpdate.ConvictedDate = updatedInmate.ConvictedDate; inmateToUpdate.LengthOfSentence = updatedInmate.LengthOfSentence; inmateToUpdate.CrimeCharged = updatedInmate.CrimeCharged; inmateToUpdate.Beefs = updatedInmate.Beefs; inmateToUpdate.Clique = updatedInmate.Clique; inmateToUpdate.Crew = updatedInmate.Crew; inmateToUpdate.Interests = updatedInmate.Interests; inmateToUpdate.MyServices = updatedInmate.MyServices; return(inmateToUpdate); }
public IActionResult CreateInmate(CreateInmateCommand newInmateCommand) { var newInmate = new Inmate { Id = Guid.NewGuid(), FirstName = newInmateCommand.FirstName, LastName = newInmateCommand.LastName, ReleaseDate = newInmateCommand.ReleaseDate, Budget = newInmateCommand.Budget, }; var repo = new InmateRepository(); var inmateThatGotCreated = repo.Create(newInmate); return(Created($"api/inmate/{inmateThatGotCreated.FirstName}{inmateThatGotCreated.LastName}", inmateThatGotCreated)); }
public IActionResult CreateInmate(AddInmateCommand newAddInmateCommand) { var newInmate = new Inmate { Id = Guid.NewGuid(), Name = newAddInmateCommand.Name, Location = newAddInmateCommand.Location, CriminalInterest = newAddInmateCommand.CriminalInterest, ReleaseDate = newAddInmateCommand.ReleaseDate, }; var repo = new InmateRepository(); var inmateThatGotCreated = repo.Add(newInmate); return(Created($"api/inmates/{inmateThatGotCreated.Name}", inmateThatGotCreated)); }
public void NoNameBookingSmokeTest() { //• Record B - A name record where the DOB places the individual under the Module.Jail.adultAge setting (18) Toolbar toolbar = new Toolbar(Toolbar.getPath()); toolbar.WaitUntilLoads(); toolbar.OpenNames(); NamesTable namesTable = new NamesTable(NamesTable.getPath()); namesTable.AddInmate(inmateRecordA); namesTable.Close(); //Test Step: Start a no-name booking. toolbar.NoNameBooking(); NoNameBooking startBooking = new NoNameBooking(NoNameBooking.getPath()); startBooking.LocationTextBox.Click(); startBooking.LocationTextBox.PressKeys("Block A Cell FJP1-1"); startBooking.LocationTextBox.PressKeys("{enter}"); startBooking.ProceedButton.Click(); Validate.Exists(BookingChecklist.getPath(), _searchTime); BookingChecklist bookingChecklist = new BookingChecklist(BookingChecklist.getPath()); bookingChecklist.InmateRecordLink.Click(); Inmate inmate = new Inmate(Inmate.getPath()); inmate.IdentifyButton.Click(); NameQuickSearch inmateNameQuickSearch = new NameQuickSearch(NameQuickSearch.getPath()); inmateNameQuickSearch.LastNameQuickSearchTextBox.TextValue = inmateRecordA; inmateNameQuickSearch.SearchButton.Click(); inmateNameQuickSearch.FindCell(inmateRecordA).Click(); inmateNameQuickSearch.SelectNameButton.Click(); bookingChecklist.Activate(); //VALIDATE:The Juvenile Instructions dialog opens and shows the text you added in setup. Assert.AreEqual(bookingChecklist.LastNameText.TextValue, inmateRecordA); bookingChecklist.Close(); inmate.Close(); }
public IActionResult CreateInmate(AddInmateCommand newInmateCommand) { var newInmate = new Inmate { id = newInmateCommand.id, Name = newInmateCommand.Name, ConvictedDate = newInmateCommand.ConvictedDate, LengthOfSentence = newInmateCommand.LengthOfSentence, CrimeCharged = newInmateCommand.CrimeCharged, Crew = newInmateCommand.Crew, Clique = newInmateCommand.Clique, Beefs = newInmateCommand.Beefs, Interests = newInmateCommand.Interests, }; var repo = new InmateRepository(); var inmateThatGotCreated = repo.Add(newInmate); return(Created($"api/Inmate/{inmateThatGotCreated.Name}", inmateThatGotCreated)); }
public IActionResult UpdateInmate(UpdateInmateCommand updatedInmateCommand, int id) { var repo = new InmateRepository(); var updatedInmate = new Inmate { Name = updatedInmateCommand.Name, ConvictedDate = updatedInmateCommand.ConvictetdDate, LengthOfSentence = updatedInmateCommand.LenghtOfSentence, CrimeCharged = updatedInmateCommand.CrimeCharged, Crew = updatedInmateCommand.Crew, Clique = updatedInmateCommand.Clique, Beefs = updatedInmateCommand.Beefs, Interests = updatedInmateCommand.Interests, }; var inmateThatGotUpdated = repo.Update(updatedInmate, id); return(Ok(inmateThatGotUpdated)); }
public void getEnemiesByInmateIdReturnsAListOfEnemies() { // Arrange var inmateRepository = new InmateRepository(); List <Inmate> result = new List <Inmate>(); // Act List <Inmate> inmate1EnemiesFromMethod = inmateRepository.GetEnemiesByInmateId(new Guid("00000000-0000-0000-0000-000000000001")); Inmate inmate3 = inmateRepository.GetInmateById(new Guid("00000000-0000-0000-0000-000000000003")); Inmate inmate9 = inmateRepository.GetInmateById(new Guid("00000000-0000-0000-0000-000000000009")); Inmate inmate12 = inmateRepository.GetInmateById(new Guid("00000000-0000-0000-0000-000000000012")); result.Add(inmate3); result.Add(inmate9); result.Add(inmate12); // Assert Assert.Equal(inmate1EnemiesFromMethod, result); }
private void BackgroundWorkerUpdateToolIssued_DoWork(object sender, DoWorkEventArgs e) { //Inmate selectedInmate; using (var db = new UnitOfWork()) { if (_isOnChecked) { db.ToolsIssuedRepo.Add(_newToolIssued); db.Commit(); _selectedInmate = db.InmatesRepo.FindById(ToolTrackerService.SelectedInmateId); } else //OnUnchecked { var toolIssued = db.ToolsIssuedRepo.FindById(_checkOutInTool.ToolIssuedId); if (toolIssued == null) { NotifyUser.SomethingIsMissing("No tool found.", "Not Found"); return; } toolIssued.DateTimeIn = DateTime.Now; toolIssued.ReturnedByInmateId = _checkOutInTool.InmateId; toolIssued.ReceivedByOfficerId = ToolTrackerService.Officer.Id; toolIssued.ToolReturned = true; try { db.ToolsIssuedRepo.Update(toolIssued); db.Commit(); } catch (EntityException ex) { ExceptionHandler.LogAndNotifyOfException(ex, ex.Message); } catch (Exception ex) { ExceptionHandler.LogAndNotifyOfException(ex, ex.Message); } } } }
public void Punish(Inmate inmate) { lock (Lock) { var utxo = inmate.Utxo; // If successfully removed, then it contained it previously, so make the punishment banned and restart its time. Inmate inmateToPunish = inmate; if (Inmates.Remove(utxo)) { // If it was noted before, then no matter the specified punishment, it must be banned. // Both the started and the last disrupted round parameters must be updated. inmateToPunish = new Inmate(utxo, Punishment.Banned, inmate.Started, inmate.LastDisruptedRoundId); } Inmates.Add(utxo, inmateToPunish); ChangeId = Guid.NewGuid(); } }
public IActionResult UpdateInmate(Inmate updatedInmate) { Inmate dbInmate = _context.Inmate.Find(updatedInmate.Id); if (ModelState.IsValid) { dbInmate.FirstName = updatedInmate.FirstName; dbInmate.LastName = updatedInmate.LastName; dbInmate.Dob = updatedInmate.Dob; dbInmate.Charges = updatedInmate.Charges; dbInmate.DateBooked = updatedInmate.DateBooked; dbInmate.HairColor = updatedInmate.HairColor; dbInmate.EyeColor = updatedInmate.EyeColor; dbInmate.Tattoos = updatedInmate.Tattoos; _context.Entry(dbInmate).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(dbInmate); _context.SaveChanges(); } return(RedirectToAction("Index")); }