Esempio n. 1
0
        public List <SiteUserViewModel> CurrentUsers(ApiCall call)
        {
            var sitedb = call.Context.WebSite.SiteDb();
            var users  = sitedb.SiteUser.All();

            List <SiteUserViewModel> result = new List <SiteUserViewModel>();

            foreach (var item in users)
            {
                SiteUserViewModel model = new SiteUserViewModel();
                model.UserId   = item.Id;
                model.UserName = item.Name;
                model.Role     = item.Role;
                result.Add(model);
            }

            return(result);
        }
Esempio n. 2
0
        public List <SiteUserViewModel> AvailableUsers(ApiCall call)
        {
            var sitedb = call.Context.WebSite.SiteDb();

            var allusers = Kooboo.Data.GlobalDb.Organization.Users(call.Context.User.CurrentOrgId);

            if (allusers == null)
            {
                allusers = new List <Data.Models.User>();
            }

            var org = Kooboo.Data.GlobalDb.Organization.Get(call.Context.User.CurrentOrgId);

            List <SiteUserViewModel> result = new List <SiteUserViewModel>();

            var currentusers = sitedb.SiteUser.All();

            foreach (var item in allusers)
            {
                if (item.Id != org.AdminUser)
                {
                    var find = currentusers.Find(o => o.UserId == item.Id);
                    if (find == null)
                    {
                        SiteUserViewModel model = new SiteUserViewModel();

                        model.UserId   = item.Id;
                        model.UserName = item.UserName;

                        result.Add(model);
                    }
                }
            }

            return(result);
        }