예제 #1
0
 public void DeleteFilesFromTp(TP tp)
 {
     var fs = _db.Documents.Where(x => x.tpid == tp.Id).ToList();
     if (fs!=null)
     {
         _db.Documents.RemoveRange(fs);
         _db.SaveChanges();
     }
 }
예제 #2
0
        public IHttpActionResult Post(TP ntp)
        {
            if (ModelState.IsValid)
            {
                ntp.name = ntp.name.Trim().Replace(" ", "").ToUpper();
                ntp.folder = Helpers.GetRightFileOrDirectoryName(ntp.name.Trim());

                var x = _tps.AddTP(ntp);
                if (x != null)
                    return Ok(x);
                else
                    return BadRequest("Не удалось добавить ТП");
            }
            else
                return BadRequest("Введены неверные данные");
        }
예제 #3
0
 public void LoadOurFromSqlite(string filename)
 {
     using (var sqli = new SqliteMan(filename))
     {
         var newlst = sqli.GetMarks();
         ClearOurTPS();
         foreach (var el in newlst)
         {
             TP a = new TP()
             {
                 name = el.c0mName.Trim().ToUpper(),
                 desc = el.c1mDesc.Trim(),
                 lat = el.mBottom,
                 //lng =el.mLeft + (el.mRight - el.mLeft),
                 lng = el.mLeft,
                 folder = Helpers.Helpers.GetRightFileOrDirectoryName(el.c0mName.Trim()).ToUpper(),
                 our = true
             };
             _db.TPS.Add(a);
         }
         _db.SaveChanges();
     }
 }
예제 #4
0
        public IHttpActionResult Put(TP tmp)
        {
            if (ModelState.IsValid)
            {
                tmp.name = tmp.name.Trim().Replace(" ", "").ToUpper();
                tmp.folder = Helpers.GetRightFileOrDirectoryName(tmp.name.Trim());
                var t = _tps.GetTPbyId(tmp.Id);
                if (t != null)
                {
                    string ppath = HttpContext.Current.Server.MapPath(startPath + t.folder.Trim());
                    string npath = HttpContext.Current.Server.MapPath(startPath + tmp.folder);

                    _tps.UpdateTP(tmp);

                    if (ppath != npath)
                    {
                        if (Directory.Exists(ppath))
                        {
                            Directory.Move(ppath, npath);
                        }
                    }

                    return Ok();
                }
                return BadRequest("Редактируемая ТП не найдена");
            }
            else
                return BadRequest("Не удалось изменить ТП");
        }
예제 #5
0
 public TP AddTP(TP tmp)
 {
     var t =_db.TPS.Add(tmp);
     _db.SaveChanges();
     return t;
 }
예제 #6
0
 public void UpdateTP(TP tmp)
 {
     var x = GetTPbyId(tmp.Id);
     if (x!=null)
     {
         x.name = tmp.name.Replace(" ","").Trim().ToUpper();
         x.lat = tmp.lat;
         x.lng = tmp.lng;
         x.our = tmp.our;
         x.desc = tmp.desc;
         x.folder = tmp.folder;
         _db.SaveChanges();
     }
 }