public async Task <IHttpActionResult> GetRatingTemplate(long addressId)
        {
            var tenantRole = await _context.Roles.FirstAsync(f => f.Name == "Tenant");

            var tenantRoleRatingParams = await _context.RoleParameters.Where(r => r.RoleId == tenantRole.Id).ToListAsync();

            var ratings = new List <RatingBreakdown>();

            foreach (var tenantRoleRatingParam in tenantRoleRatingParams)
            {
                var roleParam = new RoleParameter();
                EfMapper.Map(tenantRoleRatingParam, roleParam);
                var rating = new RatingBreakdown();
                rating.RoleParameter   = roleParam;
                rating.RoleParameterId = roleParam.Id;
                ratings.Add(rating);
            }

            var addressString = _context.Addresses.First(a => a.Id == addressId).AddressLine1;

            return(Ok(
                       new PersonRatingViewModel {
                PersonRating = new PersonRating
                {
                    RatingBreakdowns = ratings, DateCreated = DateTime.Today, DateUpdated = DateTime.Today, AddressId = addressId
                },
                Address = addressString
            }));
        }
    private RoleParameter RoleScrollow()
    {
        scrollPos = GUI.BeginScrollView(new Rect(0, 80, position.width - 0, position.height - 80), scrollPos, new Rect(0, 80, 2100, 650));  // 创建ScrollView
        EditorGUILayout.Space();
        CurrentRoleParameter = RoleParameter();

        GUI.EndScrollView();
        return(CurrentRoleParameter);
    }
            public static int Insert(RoleParameter param)
            {
                string sql =
                    $"INSERT INTO [dbo].[Role] ([Name], [Description], [Disable], [CreateTime], [UpdateTime])VALUES ('{param.Name}','{param.Description}', {param.Disable}, GETUTCDATE(), GETUTCDATE());";

                using (var db = new MsSql(DbName.Official)) {
                    return(db.Write(CommandType.Text, sql));
                }
            }
            public static int Update(RoleParameter param)
            {
                var sql =
                    Format(
                        "UPDATE [dbo].[Role]SET [Name]='{1}',[Description]='{2}',[Disable]={3},[UpdateTime]=GETUTCDATE()WHERE ID={0}",
                        param.ID, param.Name, param.Description, param.Disable);

                using (var db = new MsSql(DbName.Official)) {
                    return(db.Write(CommandType.Text, sql));
                }
            }
    private void CreateUi()                                                                         //创建界面
    {
        CurrentRoleParameter.roleName = Enum.GetName(typeof(CHARACTORSELECT), CreateRoleFxItems()); //CreateRoleFxItems ().ToString().Split('_')[1];  //选择角色区域

        EditorGUILayout.BeginVertical();
        //循环3次,依次创建 3个
        for (int i = 0; i < 3; i++)
        {
            CurrentRoleParameter = RoleScrollow();
        }
        EditorGUILayout.EndVertical();
    }
            public static int Delete(RoleParameter param)
            {
                string sql =
                    $@"
                        DELETE FROM [dbo].[Role]
                        WHERE ID={param.ID}
                    ";

                using (var db = new MsSql(DbName.Official)) {
                    return(db.Write(CommandType.Text, sql));
                }
            }
Example #7
0
 public ActionResult Edit(RoleParameter param)
 {
     if (param.ID > 0)
     {
         return(View(new InternalDataTransferToView
         {
             Data = DataAccessProvider.Role.GetRoleDetail(param)
         }));
     }
     else
     {
         return(View(new InternalDataTransferToView
         {
             Data = DataAccessProvider.Role.GetActions()
         }));
     }
 }
Example #8
0
        public ActionResult AjaxDel(RoleParameter param)
        {
            JsonNetResult result = new JsonNetResult();
            var           r      = new DetailResponse();

            try
            {
                r.Code = (DataAccessProvider.Role.Delete(param)).ToString();
                r.Ok   = true;
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                r.Code = "-11";
            }

            result.Data = r;
            return(result);
        }
            public static DataSet GetRoleDetail(RoleParameter param)
            {
                var sql = Format(@"
                        SELECT *
                        FROM [dbo].[Actions];

                        SELECT *
                        FROM [dbo].[Role]
                        WHERE ID={0};

                        SELECT ActionID
                        FROM [dbo].[RoleAction]
                        WHERE RoleID={0};
                    ", param.ID);

                using (var db = new MsSql(DbName.Official)) {
                    return(db.DataSet(CommandType.Text, sql));
                }
            }
Example #10
0
        public ActionResult AjaxEdit(RoleParameter param)
        {
            JsonNetResult result = new JsonNetResult();
            var           r      = new DetailResponse();

            try
            {
                r.Code = ((param.ID > 0)
                    ? DataAccessProvider.Role.Update(param)
                    : DataAccessProvider.Role.Insert(param)).ToString();

                if (param.ActionIDs == null || param.ActionIDs.Count == 0)
                {
                    DataAccessProvider.RoleAction.Clear(param.ID);
                }
                else
                {
                    List <string> tmp = new List <string>();
                    foreach (string ActionID in param.ActionIDs)
                    {
                        tmp.Add(string.Format("({0}, {1})", param.ID, ActionID));
                    }
                    DataAccessProvider.RoleAction.Update(param.ID, string.Join(",", tmp.ToArray()));
                }

                r.Ok = true;
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                r.Code = "-11";
            }

            result.Data = r;
            return(result);
        }
Example #11
0
 private void SaveRoleParameter(RoleParameter role) // 将信息保存至 txt 中, 参数为 当前角色
 {
 }
Example #12
0
        /// <summary>
        /// 保存角色
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public async Task <IActionResult> Save(RoleParameter role)
        {
            var result = await roleManager.SaveAsync(role);

            return(Json(result));
        }
Example #13
0
        /// <summary>
        /// 保存角色请求处理接口
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public async Task <ReturnResult> SaveAsync(RoleParameter parameter)
        {
            ReturnResult result = new ReturnResult();
            var          role   = Mapper.Map <Role>(parameter);

            //新建角色
            if (role.Id <= 0)
            {
                role.Name = role.Name?.Trim();
                //验证角色名
                if (string.IsNullOrEmpty(role.Name))
                {
                    result.IsSuccess = false;
                    result.Message   = "角色名不能为空";
                    return(result);
                }
                var tmpRole = await context.Roles.Where(c => c.Name == role.Name && c.IsDel == false).FirstOrDefaultAsync();

                if (tmpRole != null)
                {
                    result.IsSuccess = false;
                    result.Message   = "角色名重复";
                    return(result);
                }
                //创建
                context.Roles.Add(role);
                await context.SaveChangesAsync();
            }
            //编辑角色
            else
            {
                var oldRole = await context.Roles.Where(c => c.Id == role.Id).FirstOrDefaultAsync();

                //验证角色ID
                if (oldRole == null || oldRole.IsDel)
                {
                    result.IsSuccess = false;
                    result.Message   = "角色已删除";
                    return(result);
                }
                //验证角色名
                role.Name = role.Name?.Trim();
                if (string.IsNullOrEmpty(role.Name))
                {
                    result.IsSuccess = false;
                    result.Message   = "角色名不能为空";
                    return(result);
                }
                var tmpRole = await context.Roles.Where(c => c.Name == role.Name && c.IsDel == false).FirstOrDefaultAsync();

                if (tmpRole != null && tmpRole.Id != oldRole.Id)
                {
                    result.IsSuccess = false;
                    result.Message   = "角色名重复";
                    return(result);
                }
                //更新角色
                oldRole.Name = role.Name;
                oldRole.Memo = role.Memo;
                await context.SaveChangesAsync();
            }
            return(result);
        }