コード例 #1
0
 public void InsertOrUpdate(DamageLocation damagelocation)
 {
     if (damagelocation.Id == default(int)) {
         // New entity
         context.DamageLocations.Add(damagelocation);
     } else {
         // Existing entity
         context.Entry(damagelocation).State = EntityState.Modified;
     }
 }
コード例 #2
0
ファイル: RealTimeHub.cs プロジェクト: dtsagile/dmg-signalr
        /// <summary>
        /// Adds damage location to db and pushes it to clients
        /// </summary>
        /// <param name="id"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="pointType"></param>
        public void AddDamageLocation(double lat, double lng, string pointType)
        {
            Logger.Info("AddDamageLocation called with lat, lng: " + lat + ", " + lng + " and pointType: " + pointType);

            //update user location in SQL Server
            DamageLocation d = new DamageLocation();
            d.DamageType = pointType;
            d.Lat = lat;
            d.Lng = lng;
            d.RecordedAt = DateTime.Now;
            DamageRepo.InsertOrUpdate(d);
            DamageRepo.Save();

            //push to all users
            Clients.gotNewDamageLocation(new { lat = lat, lng = lng, pointType = pointType });
        }