示例#1
0
        public Athlete SyncMyAthlete(Athlete athleteOnMobile)
        {
            Athlete athlete = this.getAthlete();

            if (athlete.AthleteID != athleteOnMobile.AthleteID)
            {
                throw new Exception("AthleteID!");
            }

            if (athlete.IsDifferent(athleteOnMobile) == false)
            {
                return(null);
            }

            if ((athlete.TimeModified - athleteOnMobile.TimeModified).TotalSeconds > 1) //athlete.TimeModified > athleteOnMobile.TimeModified)
            {
                return(athlete);                                                        // send web athlete back to the mobile
            }
            else
            {
                // update the server's record
                athleteOnMobile.CopyTo(athlete, false);
                athlete.TimeModified = athlete.TimeModified;
                db.SaveChanges();
                return(null);
            }
        }