Esempio n. 1
0
        public JsonResult GetListUserInGroup(string deparment)
        {
            var list = (from a in _context.AdGroupUsers
                        join b in _context.AdUserInGroups on a.GroupUserCode equals b.GroupUserCode into b2
                        from b1 in b2.DefaultIfEmpty()
                        join c in _context.Users on b1.UserId equals c.Id into c2
                        from c1 in c2.DefaultIfEmpty()
                        where a.GroupUserCode == deparment
                        select new
            {
                c1
            }).ToList();
            List <DispatchesUser1> list1 = new List <DispatchesUser1>();

            foreach (var item in list)
            {
                if (item.c1 != null)
                {
                    DispatchesUser1 dt = new DispatchesUser1();
                    dt.Id        = item.c1.Id;
                    dt.GivenName = item.c1.GivenName;
                    list1.Add(dt);
                }
            }
            return(Json(list1));
        }
Esempio n. 2
0
        public JsonResult GetDispatchesUser()
        {
            var user      = _context.Users.FirstOrDefault(x => x.UserName == ESEIM.AppContext.UserName);
            var deparment = _context.AdUserInGroups.FirstOrDefault(x => x.UserId == user.Id);
            var query     = from a in _context.AdUserInGroups
                            join b in _context.Users on a.UserId equals b.Id into b2
                            from b1 in b2.DefaultIfEmpty()
                            where a.GroupUserCode == deparment.GroupUserCode &&
                            a.UserId != user.Id
                            select new
            {
                a,
                b1
            };

            var list = query.ToList();
            List <DispatchesUser1> list1 = new List <DispatchesUser1>();

            foreach (var item in list)
            {
                if (item.b1 != null)
                {
                    DispatchesUser1 dt = new DispatchesUser1();
                    dt.Id        = item.b1.Id;
                    dt.GivenName = item.b1.GivenName;
                    list1.Add(dt);
                }
            }
            return(Json(list1));
        }