Example #1
0
        public JsonResult addtagJSON(string n)
        {
            Database1Entities1 db = new Database1Entities1();

            userCTag t = new userCTag();

            t.cTagName = n;


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

            dbnew.userCTags.Add(t);
            dbnew.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public JsonResult ShowContactdetailJSON(string a)
        {
            //var tagofafile=cx.ftagdetails

            /* int id = Int32.Parse(a);
             * contact1 c1n=null;
             * c1n = db.contacts1.Find(id);
             *
             *   // ftd = cx.ftagdetails.Where(x=>x.username.Equals(a)).ToList();
             *
             *   contactandtags cat = new contactandtags(c1n);
             *
             *   // String usertag = Session["username"].ToString();
             *
             *
             *   return this.Json(cat, JsonRequestBehavior.AllowGet);*/
            //var tagofafile=cx.ftagdetails

            int id = Int32.Parse(a);

            c1 = dbnew.contacts1.Find(id);

            contact1 c1nn = null;

            c1nn = dbnew.contacts1.Find(id);

            //  ftd = cx.ftagdetails.Where(x => x.username.Equals(a)).ToList();
            var userid = Int32.Parse(Session["userId"].ToString());

            ftd = dbnew.fTagDetails1.Where(x => x.uid == userid && x.cid == id).ToList();
            List <contactCTag> cct = new List <contactCTag>();

            cct = dbnew.contactCTags.Where(x => x.cid == id).ToList();
            int i = 0;

            lt1 = new List <userCTag>();
            foreach (var x in cct)
            {
                var uc = dbnew.userCTags.Find(cct[i].uctid);
                lt1.Add(uc);
                i++;
            }
            List <userCTag> unassignedctag = new List <userCTag>();

            unassignedctag = c.getallctag(userid);
            var unass = unassignedctag.Where(p => !lt1.Any(l => p.Id.Equals(l.Id))).ToList();



            contact1 cat1 = new contact1();

            cat1.Id                 = c1nn.Id;
            cat1.uid                = c1nn.uid;
            cat1.firstName          = c1nn.firstName;
            cat1.middleName         = c1nn.middleName;
            cat1.lastName           = c1nn.lastName;
            cat1.dob                = c1nn.dob;
            cat1.note               = c1nn.note;
            cat1.phoneticFirstName  = c1nn.phoneticFirstName;
            cat1.phoneticMiddleName = c1nn.phoneticMiddleName;
            cat1.phoneticLastName   = c1nn.phoneticLastName;
            cat1.prefix             = c1nn.prefix;
            cat1.suffix             = c1nn.suffix;
            cat1.nickName           = c1nn.nickName;
            cat1.jobTitle           = c1nn.jobTitle;
            cat1.company            = c1nn.company;
            cat1.department         = c1nn.department;

            List <fTagDetail1> a123 = new List <fTagDetail1>();

            foreach (var x in ftd)
            {
                fTagDetail1 child = new fTagDetail1();
                child.Id          = x.Id;
                child.uid         = x.uid;
                child.cid         = x.cid;
                child.orignalName = x.orignalName;
                child.virtualName = x.virtualName;
                child.url         = x.url;
                a123.Add(child);
            }
            List <userCTag> ucl         = new List <userCTag>();
            List <userCTag> uclunassign = new List <userCTag>();

            foreach (var p in lt1)
            {
                userCTag uc = new userCTag();
                uc.Id       = p.Id;
                uc.cTagName = p.cTagName;
                uc.uid      = p.uid;
                ucl.Add(uc);
            }
            foreach (var p in unass)
            {
                userCTag uc = new userCTag();
                uc.Id       = p.Id;
                uc.cTagName = p.cTagName;
                uc.uid      = p.uid;
                uclunassign.Add(uc);
            }
            List <mobileNo> mobnums = new List <mobileNo>();
            var             mobnum  = dbnew.mobileNoes.Where(x => x.cid == id && x.uid == userid);

            foreach (var q   in mobnum)
            {
                mobileNo mns = new mobileNo();
                mns.Id     = q.Id;
                mns.cid    = q.cid;
                mns.uid    = q.uid;
                mns.mid    = q.mid;
                mns.number = q.number;
                mobnums.Add(mns);
            }


            contactandtags cat = new contactandtags(cat1, a123, ucl, uclunassign, mobnums);

            // String usertag = Session["username"].ToString();


            return(this.Json(cat, JsonRequestBehavior.AllowGet));
        }