Esempio n. 1
0
        public JsonResult addftagJSON(string n)
        {
            //Database1Entities1 db = new Database1Entities1();

            userFTag t = new userFTag();

            t.fTagName = n;


            t.uid = Int32.Parse(Session["userId"].ToString());

            dbnew.userFTags.Add(t);
            dbnew.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult gettagsofselectedfile(string a)
        {
            int id = Int32.Parse(a);

            var file   = dbnew.fTagDetails1.Find(id);
            var userid = Int32.Parse(Session["userId"].ToString());

            ftd = dbnew.fTagDetails1.Where(x => x.uid == userid && x.cid == file.cid && x.url.Equals(file.url) && x.orignalName.Equals(file.orignalName)).ToList();
            //file.ftagname;
            //var tagsplits = tags.Split(',');
            ft1new = c.getallftag(userid);
            List <userFTag> assigned   = new List <userFTag>();
            List <userFTag> unassigend = new List <userFTag>();

            for (int j = 0; j < ft1new.Count; j++)
            {
                for (int k = 0; k < ftd.Count; k++)
                {
                    if (ftd[k].fid == ft1new[j].Id)
                    {
                        userFTag nn = new userFTag();
                        nn.Id       = ft1new[j].Id;
                        nn.uid      = ft1new[j].uid;
                        nn.fTagName = ft1new[j].fTagName;

                        assigned.Add(nn);
                    }
                    // else
                    {
                    }
                }
            }



            /* for (int k = 0; k < assigned.Count; k++)
             * {
             *   if(ft1new[j].Id==assigned[k].Id)
             *   {
             *
             *   }
             *   else
             *   {
             *       userFTag nn = new userFTag();
             *       nn.Id = ft1new[j].Id;
             *       nn.uid = ft1new[j].uid;
             *       nn.fTagName = ft1new[j].fTagName;
             *       unassigend.Add(nn);
             *   }
             *
             * }*/
            assigned = assigned.GroupBy(p => p.fTagName).Select(g => g.First()).ToList();
            var unassigend1 = ft1new.Where(p => !assigned.Any(l => p.fTagName.Equals(l.fTagName))).ToList();

            foreach (var v in unassigend1)
            {
                userFTag nn = new userFTag();
                nn.Id       = v.Id;
                nn.uid      = v.uid;
                nn.fTagName = v.fTagName;
                unassigend.Add(nn);
            }

            ct = new contactandtags(assigned, unassigend);
            return(Json(ct, JsonRequestBehavior.AllowGet));
        }