コード例 #1
0
        public IHttpActionResult SetPropertyConut()
        {
            var goverments = _governmentService.GetAllGovernmentUnits();
            var role       = _accountUserService.GetAccountUserRoleBySystemName(SystemAccountUserRoleNames.ParentGovernmentorAuditor);

            foreach (var g in goverments)
            {
                g.PropertyConut = g.Properties.Count;
                if (g.ParentGovernmentId != 0)
                {
                    var parent = _governmentService.GetGovernmentUnitById(g.ParentGovernmentId);

                    g.ParentName = parent.Name;
                }

                _governmentService.UpdateGovernmentUnit(g);

                var users = g.Users;
                foreach (var user in users)
                {
                    if (g.ParentGovernmentId == 0)
                    {
                        if (user.AccountUserRoles.Where(ur => ur.Name == SystemAccountUserRoleNames.ParentGovernmentorAuditor).Count() == 0)
                        {
                            user.AccountUserRoles.Add(role);
                            _accountUserService.UpdateAccountUser(user);
                        }
                    }
                }
            }


            return(Ok("赋值完成"));
        }
コード例 #2
0
        public IHttpActionResult AutocompleteByName(string governmentName)
        {
            var governments = _governmentService.GetAllGovernmentUnits(governmentName, 0, 15, true);

            var response = new ListResponse <SimpleGovernmentUnitModel>();

            response.Data = governments.Select(g => {
                return(new SimpleGovernmentUnitModel
                {
                    Id = g.Id,
                    Name = g.Name
                });
            });


            //activity log
            _accountUserActivityService.InsertActivity("AutocompleteByName", "查询 名称包含 {0} 的单位", governmentName);

            return(Ok(response));
        }