Пример #1
0
        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);
        }
Пример #2
0
        public IEnumerable <HankiesRuleViolation> GetRuleViolations()
        {
            foreach (var violation in
                     CoordinatesRules.GetCoordinatesRuleViolations(this))
            {
                yield return(violation);
            }

            yield break;
        }
Пример #3
0
        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);
            }
        }