/// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <ActionResult> AddRole(string param)
        {
            JsonResponse result = new JsonResponse();

            try
            {
                RoleEntity entity = JsonConvert.DeserializeObject <RoleEntity>(param);
                entity.CreationTime = DateTime.Now;
                entity.CreateUserId = LoginUser.Id;
                int roleId = await _roleServices.AddRole(entity);

                if (roleId == -1)
                {
                    result.code = ResponseCode.Fail;
                    result.msg  = "该角色名已存在";
                    return(Json(result));
                }
                await _logServices.WriteSystemLog(LoginUser.Id, "添加角色", string.Format("信息={0},结果:{1}", param, roleId));

                return(Json(result));
            }
            catch (Exception ex)
            {
                await _logServices.WriteExceptionLog(LoginUser.Id, "添加角色", ex.ToString());

                result.code = ResponseCode.Fail;
                result.msg  = "添加角色异常," + ex.ToString();
                return(Json(result));
            }
        }
Exemplo n.º 2
0
 public int Post([FromBody] RoleEntity role)
 {
     if (role != null)
     {
         return(roleServices.AddRole(role));
     }
     return(0);
 }
Exemplo n.º 3
0
 public int Post([FromBody] RoleViewModel role)
 {
     if (role != null)
     {
         Mapper.Initialize(cfg => cfg.CreateMap <RoleViewModel, RoleEntity>());
         var roleEntity = Mapper.Map <RoleViewModel, RoleEntity>(role);
         return(roleServices.AddRole(roleEntity));
     }
     return(0);
 }
Exemplo n.º 4
0
        public IActionResult AddRole(CreateOrUpdateRoleDto model)
        {
            var role   = _mapper.Map <Role>(model);
            var result = _roelServices.AddRole(role);

            if (result != null)
            {
                return(Ok(new { message = "添加角色成功", result }));
            }

            return(new JsonResult(new { code = "000005", message = "添加失败" }));
        }
Exemplo n.º 5
0
 public int Add(VRole vRole)
 {
     return(_role.AddRole(vRole));
 }