Пример #1
0
 public FiasViewModel(FIASModel f)
 {
     fias = new FIASModel();
     //материализовать объект на форме
     using (var dc = new eORDEREntities())
     {
         var id  = f.ID;
         var rec = (from al in dc.O_HouseSeriesAddrList.Where(h => h.lngHouseSeriesAddrListID == id) select al).FirstOrDefault();
         fias.Addr1 = rec.strAddr.ToString();
         var rec2 = (from hsa in dc.O_HSAList.Where(h => h.HSAID == id) select hsa).FirstOrDefault();
         if (rec2 == null)
         {
             fias.ID    = 0;
             fias.Addr2 = "";
             fias.Fias  = "";
             fias.Lat   = 0M;
             fias.Lon   = 0M;
             fias.Kladr = "";
             fias.OCATO = "";
         }
         else
         {
             fias.ID    = rec2.HSAID.GetValueOrDefault();
             fias.Addr2 = rec2.Address.ToString();
             fias.Fias  = rec2.FiasCode.ToString();
             fias.Lat   = (decimal)rec2.Geo_Lat.GetValueOrDefault();
             fias.Lon   = (decimal)rec2.Geo_Lon.GetValueOrDefault();
             fias.Kladr = rec2.KladrCode.ToString();
             fias.OCATO = rec2.Ocato.ToString();
         }
     }
 }
Пример #2
0
        private void Save()
        {
            var id = fias.ID;

            using (var dc = new eORDEREntities())
            {
                var hsa = (from altadr in dc.O_HSAList
                           where altadr.HSAID == id
                           select altadr).FirstOrDefault();
                if (hsa == null)  //если запись не найдена
                {
                    //добавим новую
                    hsa       = new O_HSAList();
                    hsa.HSAID = id;
                    dc.O_HSAList.Add(hsa);
                }
                hsa.Address   = fias.Addr2;
                hsa.FiasCode  = fias.Fias;
                hsa.KladrCode = fias.Kladr;
                hsa.Ocato     = fias.OCATO;
                hsa.Geo_Lat   = fias.Lat;
                hsa.Geo_Lon   = fias.Lon;
                hsa.Check     = false;
                hsa.Unknown   = false;
                dc.SaveChanges();
            }
        }
Пример #3
0
        private void Unknown()
        {
            var id = fias.ID;

            using (var dc = new eORDEREntities())
            {
                var hsa = (from altadr in dc.O_HSAList
                           where altadr.HSAID == id
                           select altadr).FirstOrDefault();
                if (hsa != null)  //если запись найдена
                {
                    hsa.Unknown = true;
                    dc.SaveChanges();
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Получить полный список адресов из БД
 /// </summary>
 /// <returns></returns>
 private List <FIASModel> LoadAddrList() //IQueryable<FIASModel> LoadAddrList()
 {
     using (var dc = new eORDEREntities())
     {
         var query = (from al in dc.O_HouseSeriesAddrList
                      from hsa in dc.O_HSAList.Where(h => h.HSAID == al.lngHouseSeriesAddrListID).DefaultIfEmpty()
                      select new FIASModel
         {
             ID = al.lngHouseSeriesAddrListID,
             Addr1 = al.strAddr,
             Fias = hsa.FiasCode,
             Addr2 = hsa.Address,
             Check = hsa.Check
                     //isEdited = false
         }).ToList();
         return(query);
     }
 }