Exemplo n.º 1
0
        public IHttpActionResult Create(DxRoleViewModel model)
        {
            RoleIdentifyCodeBuilder roleIdentifyCodeBuilder = new RoleIdentifyCodeBuilder();

            model.IdentifyCode    = roleIdentifyCodeBuilder.Build;
            model.ClientId        = (int)DxClient.Administrator;
            model.ClientName      = DxClient.Administrator.GetDescription();
            model.CreatedBy       = UserContext.LoginName;
            model.CreatedByUserId = UserContext.Id;
            model.IsEnabled       = true;
            model.IsBuiltin       = false;
            model.IsDeleted       = false;
            var entity = model.ToEntity();

            entity.CreatedOn = DateTime.Now;
            int            a = _dxRoleService.Insert(entity);
            DataSourceForm dataSourceForm = new DataSourceForm();

            if (a > 0)
            {
                dataSourceForm.IsSuccess = true;
                dataSourceForm.Message   = "添加成功!";
                //添加操作日志
                //logger.CreateLog("新增角色", entity);
            }
            else
            {
                dataSourceForm.IsSuccess = false;
                dataSourceForm.Message   = "添加失败!";
            }

            return(Ok(dataSourceForm));
        }
Exemplo n.º 2
0
 public static DxRole ToEntity(this DxRoleViewModel entity)
 {
     return(entity.MapTo <DxRoleViewModel, DxRole>());
 }