Exemplo n.º 1
0
        public async Task <IHttpActionResult> PostByUids([FromBody] string[] uids)
        {
            List <uidt> uts = new List <uidt>();

            foreach (string uid in uids)
            {
                uidt temp = await db.uidts.Where(b => b.uid == uid)
                            .Select(c => c)
                            .FirstOrDefaultAsync();

                uts.Add(temp);
            }

            //if (uts == null)
            //{
            //    return NotFound();
            //}

            List <XRefSpec> xfs = new List <XRefSpec>();

            foreach (uidt ut in uts)
            {
                XRefSpec xf = Newtonsoft.Json.JsonConvert.DeserializeObject <XRefSpec>(ut.objectStr);
                xfs.Add(xf);
            }
            return(Ok(xfs));
        }
Exemplo n.º 2
0
        private void SaveData(string path)
        {

            XRefMap xref = Microsoft.DocAsCode.Common.YamlUtility.Deserialize<XRefMap>(path);
            foreach (var spec in xref.References)
            {
                uidt t = new uidt();
                t.uid = spec["uid"];
                t.objectStr = Newtonsoft.Json.JsonConvert.SerializeObject(spec);
                db.uidts.Add(t);
                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> GetByUid(string uid)
        {
            uidt ut = await db.uidts.Where(b => b.uid == uid)
                      .Select(c => c)
                      .FirstOrDefaultAsync();

            if (ut == null)
            {
                return(NotFound());
            }
            XRefSpec xf = Newtonsoft.Json.JsonConvert.DeserializeObject <XRefSpec>(ut.objectStr);

            return(Ok(xf));
        }