public async Task <IActionResult> UnexcusedAbsence(string id) { Offense offense = await offenseRepository.GetOffenseByID(id); offense.NeedApproval = false; await offenseRepository.Update(offense); TempData["StatusMessage"] = "Absence has been marked as unexcused."; return(await OffensesApproval()); }
public async Task <IActionResult> NotifiedLeaveEarly(string id) { Offense offense = await offenseRepository.GetOffenseByID(id); offense.NeedApproval = false; await offenseRepository.Update(offense); TempData["StatusMessage"] = "Offense has been marked as notified."; return(await OffensesApproval()); }
public async Task RecordDetectedOffense(ApplicationUser user, WorkingDay workingDay, OffenseDegree degree) { WorkingDay userWorkingDay; if (workingDay == null) // user was absent { // Create new empty working day object for the day that the user miss userWorkingDay = new WorkingDay(user.Id, DateTime.Today.AddDays(-1)); await workingDayRepository.Add(userWorkingDay); } else { userWorkingDay = workingDay; } Offense offense; if (await HasAllowance(user.Id, userWorkingDay, degree)) { offense = new Offense(userWorkingDay.ID, 0, degree) { HasAllowance = true }; } else { // Get how many times this offense occurred within // the last 90 days and increment it by one (for absence, count the unexcused ones only) int occurrence; if (degree == OffenseDegree.Absence) { occurrence = await offenseRepository.CountAbsenceInLast90Days(user.Id, userWorkingDay) + 1; } else { occurrence = await offenseRepository.CountOffensesInLast90Days(user.Id, userWorkingDay, degree) + 1; } // If the occurence is not within the Occurrence enum, assign it to the last enum (FifthOrMore) if (!Enum.IsDefined(typeof(Occurrence), occurrence)) { Array occurrencesArray = Enum.GetValues(typeof(Occurrence)); // Get the last object in the occurence enum & assign it to occurrence occurrence = (int)occurrencesArray.GetValue(occurrencesArray.Length - 1); } // Get penalty percent per day desired for this offense int penaltyPercent = ruleRepository.GetPenaltyPercent(degree, (Occurrence)occurrence); // Create new offence object & save it offense = new Offense(userWorkingDay.ID, penaltyPercent, degree); // Check if it needs approval if (degree == OffenseDegree.Absence || degree == OffenseDegree.LeaveEarly) { offense.NeedApproval = true; } } await offenseRepository.Add(offense); }
private void PrintSubRecord(Offense record, int id) { PrintVerticalSpace(); AppendNewRow("Offense No.:", id.ToString(), 1); AppendNewRow("Case Number:", record.CaseNumber, 1); AppendNewRow("Offense Code:", record.OffenseCode, 2); AppendNewRow("Date of Crime:", record.CrimeDate.Value.ToShortDateString(), 1); AppendNewRow("Crime Country:", record.CrimeCountry, 2); AppendNewRow("Category:", record.Category, 1); AppendNewRow("Degree:", record.Degree, 2); AppendNewRow("Disposition:", record.Disposition, 1); AppendNewRow("Description:", record.Description, 1); }
public void OnTriggerEnter(Collider other) { if (other.tag == "Offense") { if (owner != null) { owner.hasflag = false; } other.GetComponent <Offense>().hasflag = true; owner = other.GetComponent <Offense>(); transform.parent = other.transform; } }
public void shootFireball(int number) { // print("Got here at least10 " +preventFireballs); if (preventFireballs) { return; } // print("Got here at least20"); Offense fireball = null; string poolName = null; switch (number) { case 1: poolName = PoolNames.pFireball1; fireball = fireball1; break; case 2: poolName = PoolNames.pFireball2; fireball = fireball2; break; case 3: poolName = PoolNames.pFireball3; fireball = fireball3; break; default: Debug.LogError("Invalid number for fireball. Must be an integer between 1 and 3."); break; } if (fireball != null && fireball.mpCost <= mp) { animator.SetTrigger(ParameterNames.Fire); GameObject obj = null; if (GameplayController.instance.useObjectPooling) { obj = ObjectPooler.instance.SpawnFromPool(poolName, fireballLocation.position, fireballLocation.rotation); } else { obj = (GameObject)Instantiate(fireball.gameObject, fireballLocation.position, fireballLocation.rotation); } //obj.GetComponent<Offense>().unitID = unitID; InitFireballProperties(obj.GetComponent <Offense>()); addMP(-fireball.mpCost); } }
//If the logic is too complicated, make this method call a coroutine. public IEnumerator ThinkRoutine(AIController controller) { RaycastHit2D hitFireball = controller.CheckRayCast(lookDistance); yield return(null); if (controller.unit.currentShield) { currentShieldLevel = controller.unit.currentShield.numberValue; } else { currentShieldLevel = 0; } if (hitFireball) { Debug.Log("Got here hit fireball"); Offense fireball = hitFireball.collider.GetComponent <Offense>(); if (currentShieldLevel == 0 || currentShieldLevel != fireball.numberValue) { switch (fireball.numberValue) { case 1: commandArr[0] = shield1; break; case 2: commandArr[0] = shield2; break; case 3: commandArr[0] = shield3; break; } controller.AddToActionQueue(commandArr); } } else { if (currentShieldLevel != 0) { commandArr[0] = stopShield; controller.AddToActionQueue(commandArr); } } controller.thinking = false; }
public async Task <IActionResult> ExcusedAbsence(string id) { Offense offense = await offenseRepository.GetOffenseByID(id); offense.NeedApproval = false; offense.PenaltyPercent = 0; await offenseRepository.Update(offense); WorkingDay workingDay = offense.WorkingDay; await workingDayRepository.CheckAbsencesInRange(workingDay.UserID, workingDay.Date.AddDays(1), DateTime.Today.AddDays(-1)); TempData["StatusMessage"] = "Offense has been marked as excused and no penalty imposed."; return(await OffensesApproval()); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag(TagNames.Fireball)) { collidedFireball = collision.GetComponent <Offense>(); if (collidedFireball && collidedFireball.unitID != unitID ) { addHP(-collidedFireball.damage); collidedFireball.Explode(true); } } }
public void BuildFactorsStrings() { Factors = Offense.ToString() + "-" + Defense.ToString(); CrippledFactors = CrippledOffense.ToString() + "-" + CrippledDefense.ToString(); if ((ShipRoles & ShipRoles.PFTender) == ShipRoles.PFTender) { Factors += 'P'; CrippledFactors += 'P'; } if (FighterFactors > 0) { Factors += '(' + FighterFactors + ')'; } if (CrippledFighterFactors > 0) { CrippledFactors += '(' + CrippledFighterFactors + ')'; } if (HeavyFighterFactors > 0) { Factors += '(' + HeavyFighterFactors + "H)"; } if (CrippledHeavyFighterFactors > 0) { CrippledFactors += '(' + CrippledHeavyFighterFactors + "H)"; } if (DroneBombardmentFactor > 0) { Factors += '<' + DroneBombardmentFactor + '>'; } if ((ShipRoles & ShipRoles.Escort) == ShipRoles.Escort) { Factors += "\u23f9"; CrippledFactors += "\u23f9"; } if ((ShipRoles & ShipRoles.Mauler) == ShipRoles.Mauler) { Factors += "\u271b"; CrippledFactors += "\u271b"; } if ((ShipRoles & ShipRoles.Survey) == ShipRoles.Survey) { Factors += "\u25c7"; } else if ((ShipRoles & ShipRoles.Scout) == ShipRoles.Scout) { Factors += "\u25c6"; } }
public IEnumerable <Offender> Search(Request request) { var offenseKim = new Offense(2, DateTime.Parse("2004-2-17"), "ALACHUA", "012012CF0123", "7840412A", "CRIMINAL", "FT", "GUILTY", "AGGRAVATED BATTERY WITH DEADLY WEAPON"); var offensePark = new Offense(1, DateTime.Parse("1996-12-4"), "ALACHUA", "012004111CF0", "89313", "FELONY", "FF", "GUILTY", "POSSESSION OF CONTROLLED SUBSTANCE: COCAINE"); List <Offender> results = new List <Offender> { new Offender("ANTHONY", "PARK", DateTime.Parse("1972-1-17"), "M", "American", 187, 89, "America", "Florida", "263 W 32nd PLACE APT. A, GAINESVILLE, FL 32608", new List <Offense> { offensePark }), new Offender("JONATHEN", "KIM", DateTime.Parse("1968-6-10"), "M", "British", 156, 59, "America", "Washington", "2430 Nouakchott Place,Washington, DC 20521-2430", new List <Offense> { offenseKim }) }; return(results); }
private void BindViewHolder(CachingViewHolder holder, Offense offenseCard, int position) { TextView _titleView = holder.FindCachedViewById <TextView>(Resource.Id.infractionTitle); TextView _dateView = holder.FindCachedViewById <TextView>(Resource.Id.infractionDate); TextView _timeView = holder.FindCachedViewById <TextView>(Resource.Id.infractionTime); holder.DeleteBinding(_titleView); holder.DeleteBinding(_dateView); holder.DeleteBinding(_timeView); var _titleBinding = new Binding <string, string> ( offenseCard, () => offenseCard.OffenseTitle, _titleView, () => _titleView.Text, BindingMode.OneWay ); var _dateBinding = new Binding <string, string> ( offenseCard, () => offenseCard.OffenseDate, _dateView, () => _dateView.Text, BindingMode.OneWay ); var _timeBinding = new Binding <string, string> ( offenseCard, () => offenseCard.OffenseTime, _timeView, () => _timeView.Text, BindingMode.OneWay ); holder.SaveBinding(_titleView, _titleBinding); holder.SaveBinding(_dateView, _dateBinding); holder.SaveBinding(_timeView, _timeBinding); }
public ActionResult Create(Offense offense) { var authorizedUser = new AppUser(); if (HttpContext.Session.GetString("FrscQuestionLoggedInUser") != null) { var userString = HttpContext.Session.GetString("FrscQuestionLoggedInUser"); authorizedUser = JsonConvert.DeserializeObject <AppUser>(userString); } if (!authorizedUser.Role.AccessAdminConsole || !authorizedUser.Role.AddAnswer) { return(RedirectToAction("UnauthorizedAccess", "Home")); } try { var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("FrscQuestionLoggedInUserId")); offense.DateCreated = DateTime.Now; offense.DateLastModified = DateTime.Now; offense.CreatedBy = signedInUserId; offense.LastModifiedBy = signedInUserId; if (_databaseConnection.Offenses.Where(n => n.Name == offense.Name).ToList().Count > 0) { //display notification TempData["display"] = "Unable to perform the action because this record already exist!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(offense)); } _databaseConnection.Offenses.Add(offense); _databaseConnection.SaveChanges(); //display notification TempData["display"] = "You have successfully added a new OOffense!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); } catch (Exception ex) { //display notification TempData["display"] = ex.Message; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(offense)); } }
public List <Offense> GetAllOffenses() { List <Offense> offenses = new List <Offense>(); SqlDataReader sqlDataReader = DBConnection.GetData("SELECT * FROM Offenses;"); while (sqlDataReader.Read()) { Offense o = new Offense(); o.Date = sqlDataReader.GetDateTime(0); o.VehicleId = sqlDataReader.GetInt32(1); o.PolicemanId = sqlDataReader.GetInt32(2); offenses.Add(o); } DBConnection.CloseConnection(); return(offenses); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag(TagNames.Fireball)) { Offense fireball = collision.GetComponent <Offense>(); if (fireball != null && (compareToFireball(fireball) >= 0)) { fireball.Explode(false); } else { //Have specific action for by how much the number the shield was trumped //for how much shield gauge is broken. For now simply stop the shield. unit.shieldOverpowered(); } } }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (this != obj) { return(false); } var other = (CheatingOffenseEntry)obj; if (ToCharacter == null) { if (other.ToCharacter != null) { return(false); } } else if (ToCharacter.Id != other.ToCharacter.Id) { return(false); } if (Offense == null) { if (other.Offense != null) { return(false); } } else if (!Offense.Equals(other.Offense)) { return(false); } if (other.m_mFirstOffense != m_mFirstOffense) { return(false); } return(true); }
public void OnTriggerEnter(Collider other) { if (other.tag == "Offense") { //owner不等于空则交换,等于空触发获得旗帜状态机 if (owner != null) { owner.hasFlag = false; } else { CTFGameManager.Instance.TakenFlag(); } owner = other.GetComponent <Offense>(); owner.hasFlag = true; transform.parent = other.transform; } }
public void OnTriggerEnter(Collider other) { if (other.tag == "Offense") { if (owner != null) { owner.hasFlag = false; } else { // 当前没有任何拥有者 CTFGameManager.Instance.TakeFlag(); } other.GetComponent <Offense>().hasFlag = true; transform.SetParent(other.transform); owner = other.GetComponent <Offense>(); } }
public void FillTheDirectory(string file_name) { using (var fs = new FileStream(file_name + ".txt", FileMode.Open)) using (var sr = new StreamReader(fs, Encoding.UTF8)) { while (!sr.EndOfStream) { var s = sr.ReadLine(); char[] delims = new char[] { '&' }; var ss = s.Split(delims, StringSplitOptions.RemoveEmptyEntries); var ID = ss[0]; var Name = ss[1]; var Description = ss[2]; var Value = ss[3]; Offense offense = new Offense(Name, Description, int.Parse(Value)); this.DateBaseAdd(offense, ss[0]); } } }
public void OnTriggerEnter(Collider other) { if (other.tag == "Offense") { if (owner == null) { CTFGameManager.Instance.TakenFlag(); } //被抢走 if (owner != null) { owner.hasFlag = false; } other.GetComponent <Offense>().hasFlag = true; transform.parent = other.transform; owner = other.GetComponent <Offense>(); } }
public bool TryAddAlliance(CombatUnit alliance, EncounterSide side) { if (!ValidAlliance(alliance)) { return(false); } if (side == EncounterSide.Defense) { Defense.AddAlliance(alliance); return(true); } else if (side == EncounterSide.Offense) { Offense.AddAlliance(alliance); return(true); } return(false); }
private void buttonDelete_Click(object sender, EventArgs e) { if (dateTimePicker.Text != "" && textBoxVehicle.Text != "" && textBoxPoliceman.Text != "") { Offense o = new Offense(); o.VehicleId = Convert.ToInt32(textBoxVehicle.Text); o.PolicemanId = Convert.ToInt32(textBoxPoliceman.Text); o.Date = Convert.ToDateTime(dateTimePicker.Value); if (this.offenseBusiness.DeleteOffense(o)) { MessageBox.Show("Uspesno brisanje prekrsaja"); ClearTextBox(); List <Offense> offensesList = this.offenseBusiness.GetAllOffenses(); dataGridViewOffense.DataSource = offensesList; } else { MessageBox.Show("Neuspelo registrovanje prekrsaja"); } } }
/// <summary> /// /// </summary> /// <param name="teamOffense">Offense</param> private void LoadReceiveStats(Offense teamOffense) { listView1.Columns.Add("Player"); listView1.Columns.Add("pc"); listView1.Columns.Add("yards"); listView1.Columns.Add("avg"); listView1.Columns.Add("td"); listView1.Columns.Add("lg"); listView1.Columns.Add("fmb"); Player[] players = teamOffense.GetPlayers(); for (int i = 0; i < players.Length; ++i) { CarryStatSheet stats = (CarryStatSheet)players[i].Stats[StatTypes.Receive]; if ((!playersShown.Contains(players[i]) && (stats.Touches > 0))) { listView1.Items.Add(new ListViewItem(new string[] { players[i].Name, stats.Touches.ToString(), stats.Yards.ToString(), stats.Average.ToString("0.0"), stats.Touchdowns.ToString(), stats.LongPlay.ToString(), stats.Fumbles.ToString() })); playersShown.Add(players[i]); } } }
public async Task <ActionResult <Offense> > PostOffense(Offense offense) { _offenseService.CreateOffense(offense); _context.Update(offense); //offense.CarDriver.Vehicle.Color = null; //offense.CarDriver.Vehicle.Model = null; //offense.CarDriver.Vehicle.Category = null; //offense.CarDriver.Vehicle.CarOwner = null; ////offense.CarDriver.VehicleOffenses.ForEach(i=>i.) ////_context.Entry().State = EntityState.Modified; //var v = offense.CarDriver.Vehicle; //offense.CarDriver.Vehicle = null; //var added = _context.Set<Offense>().Add(offense).Entity; //await _context.SaveChangesAsync(); ////_context.Entry(v).State = EntityState.Modified; //offense.CarDriver.Vehicle = v; //_context.Entry(added).CurrentValues.SetValues(offense); //_context.Offenses.Update(offense); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOffense", new { id = offense.Id }, offense)); }
/// <summary> /// Performs initialization of custom configuration section and validates /// any required derived <see cref="ConfigurationElement"/>s have been populated. /// </summary> private static void Init() { _config = (Offense)ConfigurationManager.GetSection("Offense"); if (_config == null) { throw new ApplicationException("No OffenseConfig section in config"); } // IsRequired field doesn't work on ConfigurationElements, http://stackoverflow.com/a/2492170 foreach (PropertyInformation propertyInformation in _config.ElementInformation.Properties) { var complexProperty = propertyInformation.Value as ConfigurationElement; if (complexProperty == null) { continue; } if (propertyInformation.IsRequired && !complexProperty.ElementInformation.IsPresent) { throw new ApplicationException(string.Format("ConfigProperty: [{0}] is required but not present", propertyInformation.Name)); } } }
public void TestSkillFacotry(SkillName s) { Skill expected = null; switch (s) { case SkillName.Learning: expected = new Learning(); break; case SkillName.Logistics: expected = new Logistics(); break; case SkillName.Offense: expected = new Offense(); break; } Skill actual = SkillFactory.GetSkill(s); Assert.Equal(expected.Name, actual.Name); }
/// <summary> /// /// </summary> /// <param name="teamOffense">Offense</param> private void LoadKickingStats(Offense teamOffense) { listView1.Columns.Add("Player"); listView1.Columns.Add("xpa"); listView1.Columns.Add("xpm"); listView1.Columns.Add("pct"); listView1.Columns.Add("fga"); listView1.Columns.Add("fgm"); listView1.Columns.Add("pct"); listView1.Columns.Add("lg"); Player[] players = teamOffense.GetPlayers(); for (int i = 0; i < players.Length; ++i) { KickPlayStatSheet stats = (KickPlayStatSheet)players[i].Stats[StatTypes.Kicking]; if ((!playersShown.Contains(players[i]) && (stats.ExtraPointsAttempted > 0))) { listView1.Items.Add(new ListViewItem(new string[] { players[i].Name, stats.ExtraPointsAttempted.ToString(), stats.ExtraPointsMade.ToString(), stats.ExtraPointPercentage.ToString("0.0"), stats.FieldGoalsAttempted.ToString(), stats.FieldGoalsMade.ToString(), stats.FieldGoalPercentage.ToString("0.0"), stats.LongPlay.ToString() })); playersShown.Add(players[i]); } } }
public EncounterPlayerContext GetPlayerContext(BasePlayer player) { if (Offense.MainPlayer == player) { return(new EncounterPlayerContext(Offense.GetShipCountOfPlayer(player), EncounterInvolvementType.Main, Offense.EncounterCard)); // Offense Main Player } else if (Defense.MainPlayer == player) { return(new EncounterPlayerContext(Defense.GetShipCountOfPlayer(player), EncounterInvolvementType.Main, Defense.EncounterCard)); // Defense Main Player } else if (Offense.AlliedPlayers.Contains(player)) { return(new EncounterPlayerContext(Offense.GetShipCountOfPlayer(player), EncounterInvolvementType.Ally, null)); } else if (Defense.AlliedPlayers.Contains(player)) { return(new EncounterPlayerContext(Defense.GetShipCountOfPlayer(player), EncounterInvolvementType.Ally, null)); } else { return(new EncounterPlayerContext(0, EncounterInvolvementType.None, null)); } }
public async Task <IActionResult> PutOffense(int id, Offense offense) { if (id != offense.Id) { return(BadRequest()); } _offenseService.CreateOffense(offense); //_context.Entry(offense).State = EntityState.Modified; _context.Update(offense); var deleteList = _context.VehicleOffenses.Where(t => !offense.CarDriver.VehicleOffenses.Contains(t) && t.CarDriver != null).ToList(); //var deleteList = _context.VehicleOffenses.Where(t => !offense.CarDriver.VehicleOffenses.Exists(x => x.Id == t.Id) && t.CarDriver != null).ToList(); foreach (var d in deleteList) { _context.VehicleOffenses.Where(s => s.Id == d.Id).First().CarDriver = null; } try { await _context.SaveChangesAsync(); } catch (Exception e) { if (!OffenseExists(id)) { return(NotFound()); } else { _logger.LogError(e.ToString()); throw; } } return(NoContent()); }
/// <summary> /// /// </summary> /// <param name="statType">StatTypes</param> /// <param name="teamOffense">Offense</param> private void SetListView(StatTypes statType, Offense teamOffense) { switch (statType) { case StatTypes.Defense: break; case StatTypes.Kicking: LoadKickingStats(teamOffense); break; case StatTypes.Pass: LoadPassStats(teamOffense); break; case StatTypes.Receive: LoadReceiveStats(teamOffense); break; case StatTypes.Return: LoadRunStats(teamOffense, statType); break; case StatTypes.Run: LoadRunStats(teamOffense, statType); break; case StatTypes.Unknown: break; case StatTypes.WonLoss: break; default: break; } }
public void Add(Offense offense) { db.Offenses.Add(offense); db.SaveChanges(); }
public void Delete(Offense Offense) { db.Offenses.Remove(Offense); db.SaveChanges(); }
public void Update(int id, Offense offense) { db.Entry(offense).State = EntityState.Modified; db.SaveChanges(); }