public IStatus <EchoLocation> Update(ICoordinates coordinates) { var response = new Status <EchoLocation>(); if (!this.IsValid) { response.AddError("Can only update valid Echo Locations"); } foreach (var violation in CoordinatesRules. GetCoordinatesRuleViolations(coordinates)) { response.AddError(violation.Rule); } // if there wernt errors go ahead and update this location. if (response.IsSuccess()) { Lattitude = coordinates.Lattitude; Longitude = coordinates.Longitude; TimeStamp = DateTimeOffset.UtcNow; } response.RespondWithObject(this); return(response); }
public IEnumerable <HankiesRuleViolation> GetRuleViolations() { foreach (var violation in CoordinatesRules.GetCoordinatesRuleViolations(this)) { yield return(violation); } yield break; }
public IEnumerable <HankiesRuleViolation> GetRuleViolations() { if (EmittedAt > DateTimeOffset.UtcNow) { yield return(new HankiesRuleViolation ("A pulse cannot be emmited at a future time.", EmittedAt)); } if (Source == null) { yield return(new HankiesRuleViolation ("Pulses must be emmited by a source", Source)); } if (Source.Owner.IsValid) { yield return(new HankiesRuleViolation ("Pulses must be from a valid source", Source)); } if (Radius >= 500) { yield return(new HankiesRuleViolation ("Pulse radius must be > 500 meters", Radius)); } if (Radius <= 40000) { yield return(new HankiesRuleViolation ("Pulse radius must be < 40000 meters (24.8 Miles)", Radius)); } foreach (var violation in CoordinatesRules. GetCoordinatesRuleViolations(Location)) { yield return(violation); } }