Exemple #1
0
 bool UpdateDistanceSelections(int id, double distance)
 {
     using (SCellsEntities db = new SCellsEntities())
     {
         db.Configuration.ProxyCreationEnabled = false;
         db.Configuration.LazyLoadingEnabled   = false;
         TierMap sCells = db.TierMap.Find(id);
         sCells.distance        = distance;
         db.Entry(sCells).State = EntityState.Modified;
         db.SaveChanges();
         int  ids1   = db.Tier.Find(sCells.tierIdStart).idS;
         int  ids2   = db.Tier.Find(sCells.tierIdFinish).idS;
         bool update = db.Section.Find(ids1).updateTier.Value;
         if (update == false)
         {
             var listUpdate = db.TierMap.Where(a => a.Tier.Section.idS == ids1 && a.Tier1.idS == ids2).ToList();
             foreach (var data in listUpdate)
             {
                 data.distance        = distance;
                 db.Entry(data).State = EntityState.Modified;
                 db.SaveChanges();
             }
             listUpdate = db.TierMap.Where(a => a.Tier.Section.idS == ids2 && a.Tier1.idS == ids1).ToList();
             foreach (var data in listUpdate)
             {
                 data.distance        = distance;
                 db.Entry(data).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         logger.Debug("SCells UpdateDistance: " + id.ToString());
         //db.Configuration.ProxyCreationEnabled = false;
         //db.Configuration.LazyLoadingEnabled = false;
         //SectionMap sCells = db.SectionMap.Find(id);
         //sCells.distance = distance;
         //db.Entry(sCells).State = EntityState.Modified;
         //db.SaveChanges();
         //SectionMap sCells1 = db.SectionMap.First(d => d.sectionIdFinish == sCells.sectionIdStart && d.sectionIdStart == sCells.sectionIdFinish);
         //sCells1.distance = distance;
         //db.Entry(sCells1).State = EntityState.Modified;
         //db.SaveChanges();
         //logger.Debug("SCells UpdateDistance: " + id.ToString());
     }
     return(true);
 }
Exemple #2
0
        public JsonResult UpdatePointsCells(int[] sectionsChosen, double distanceSelections)
        {
            using (SCellsEntities db = new SCellsEntities())
            {
                db.Configuration.ProxyCreationEnabled = false;
                db.Configuration.LazyLoadingEnabled   = false;
                for (int i = 0; i < sectionsChosen.Length; i++)
                {
                    double distanceFinal = 0;
                    for (int j = i + 1; j < sectionsChosen.Length; j++)
                    {
                        int predcessor = sectionsChosen[i];
                        int finalId    = sectionsChosen[j];
                        distanceFinal += distanceSelections;
                        TierMap sCells = db.TierMap.First(d => d.tierIdStart == predcessor && d.tierIdFinish == finalId);
                        sCells.distance        = distanceFinal;
                        db.Entry(sCells).State = EntityState.Modified;
                        db.SaveChanges();

                        //SectionMap sCells1 = db.SectionMap.First(d => d.sectionIdFinish == sCells.sectionIdStart && d.sectionIdStart == sCells.sectionIdFinish);
                        //sCells1.distance = distanceFinal;
                        //db.Entry(sCells1).State = EntityState.Modified;
                        //db.SaveChanges();
                    }
                }
                //for (int i = 0; i < sectionsChosen.Length; i++)
                //{
                //    double distanceFinal = 0;
                //    for (int j = i + 1; j < sectionsChosen.Length; j++)
                //    {
                //        int predcessor = sectionsChosen[i];
                //        int finalId = sectionsChosen[j];
                //        distanceFinal += distanceSelections;
                //        SectionMap sCells = db.SectionMap.First(d => d.sectionIdStart == predcessor && d.sectionIdFinish == finalId);
                //        sCells.distance = distanceFinal;
                //        db.Entry(sCells).State = EntityState.Modified;
                //        db.SaveChanges();
                //        SectionMap sCells1 = db.SectionMap.First(d => d.sectionIdFinish == sCells.sectionIdStart && d.sectionIdStart == sCells.sectionIdFinish);
                //        sCells1.distance = distanceFinal;
                //        db.Entry(sCells1).State = EntityState.Modified;
                //        db.SaveChanges();
                //    }
                //}
            }
            logger.Debug("SCells UpdatePointsCells");
            return(Json(1, JsonRequestBehavior.AllowGet));
        }