public async Task DeleteBody(string symbol) { var bodyToDelete = Bodies.FirstOrDefault(x => x.Symbol == symbol); bodyToDelete.QuantityInStock = 0; await UpdateBody(bodyToDelete); }
public async Task UpdateBody(Body body) { var bodyToUpdate = Bodies.FirstOrDefault(x => x.Symbol == body.Symbol); bodyToUpdate.QuantityInStock = body.QuantityInStock; bodyToUpdate.Price = body.Price; bodyToUpdate.Name = body.Name; context.Body.Update(bodyToUpdate); await context.SaveChangesAsync(); }
protected override void AnalyzeNewBodyData() { var body = Bodies.FirstOrDefault(b => b.IsTracked); if (body == null) { return; } var hand = body.Joints[JointType.HandRight].Position; SetValues(hand); InvokeDetected(body.TrackingId); }
public async Task DeleteBody(string symbol) { try { var bodyToDelete = Bodies.FirstOrDefault(x => x.Symbol == symbol); context.Body.Remove(bodyToDelete); await context.SaveChangesAsync(); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { return; } }
protected override void AnalyzeNewBodyData() { var body = Bodies.FirstOrDefault(b => b.IsTracked); if (body == null) { return; } var clapFinished = IsClapFinished(body); if (clapFinished) { InvokeDetected(body.TrackingId); } }
protected override void AnalyzeNewBodyData() { var body = Bodies.FirstOrDefault(b => b.IsTracked); if (body == null) { return; } var handIsUpInFrame = DetermineHandUp(body); if (HandUp == handIsUpInFrame) { return; } HandUp = handIsUpInFrame; OnHandUpChanged(body.TrackingId); }
/// <summary> /// Add a range of bodies. /// Commit it to storage if required. /// </summary> /// <param name="bodies"></param> /// <param name="commit"></param> public static void AddRange(List <Body> bodies, bool commit = false) { foreach (var body in bodies) { var doesExist = Bodies.FirstOrDefault(x => x.BodyNo == body.BodyNo && x.KillDate == body.KillDate) != null; if (doesExist) { continue; } Bodies.Add(body); } if (commit) { Commit(); } }
public override string Print(bool link = true, DwarfObject pov = null) { string eventString = GetYearTime(); if (Bodies.Count > 1) { eventString += "the bodies of "; for (int i = 0; i < Bodies.Count; i++) { eventString += Bodies[i].ToLink(link, pov, this) ?? "UNKNOWN HISTORICAL FIGURE"; if (i != Bodies.Count - 1) { if (i == Bodies.Count - 2) { eventString += " and "; } else { eventString += ", "; } } } eventString += " were "; } else { eventString += "the body of "; eventString += Bodies.FirstOrDefault()?.ToLink(link, pov, this) ?? "UNKNOWN HISTORICAL FIGURE"; eventString += " was "; } switch (AbuseType) { case AbuseType.Impaled: eventString += "impaled on a "; eventString += !string.IsNullOrWhiteSpace(Material) ? Material + " " : ""; if (!string.IsNullOrWhiteSpace(ItemSubType) && ItemSubType != "-1") { eventString += ItemSubType; } else { eventString += !string.IsNullOrWhiteSpace(ItemType) ? ItemType : "UNKNOWN ITEM"; } break; case AbuseType.Piled: eventString += "added to a " + PileType.GetDescription(); break; case AbuseType.Flayed: eventString += "flayed"; break; case AbuseType.Hung: eventString += "hung"; break; case AbuseType.Mutilated: eventString += "horribly mutilated"; break; case AbuseType.Animated: eventString += "animated"; break; default: eventString += "abused"; break; } eventString += " by "; if (HistoricalFigure != null) { eventString += HistoricalFigure.ToLink(link, pov, this); if (Abuser != null) { eventString += " of "; } } if (Abuser != null) { eventString += Abuser.ToLink(link, pov, this); } if (Structure != null) { eventString += " in "; eventString += Structure.ToLink(link, pov, this); } if (Site != null) { eventString += " in "; eventString += Site.ToLink(link, pov, this); } else if (Region != null) { eventString += " in "; eventString += Region.ToLink(link, pov, this); } else if (UndergroundRegion != null) { eventString += " in "; eventString += UndergroundRegion.ToLink(link, pov, this); } eventString += PrintParentCollection(link, pov); eventString += "."; return(eventString); }
public Body GetBody(string symbol) { return(Bodies.FirstOrDefault(x => x.Symbol == symbol)); }