コード例 #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 Update(int id, GovernmentUnitModel governmentUnitModel)
        {
            var government = _governmentService.GetGovernmentUnitById(id);

            if (government == null || government.Deleted)
            {
                return(NotFound());
            }

            government = governmentUnitModel.ToEntity(government);

            _governmentService.UpdateGovernmentUnit(government);
            _accountUserActivityService.InsertActivity("UpdateGovernment", "更新名为 {0} 的单位", government.Name);
            return(Ok(government.ToModel()));
        }