Exemplo n.º 1
0
        public async Task <ReturnResult> EditKey([FromBody] EditKey request)
        {
            if (int.Parse(request.SectionID) <= 0)
            {
                throw new AppException("栏目不能为空");
            }
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                throw new AppException("名称不能为空");
            }
            KeyContent keyContent = await KeyContentManager.GetByIdAsync(int.Parse(request.ID));

            int iUID = LoginManager.GetUserID();

            if (keyContent.CreateUserID != iUID)
            {
                throw new AppException(ReturnResultStatus.Illegal, "非法操作");
            }
            var mapper = new MapperConfiguration(x => x.CreateMap <EditKey, KeyContent>()).CreateMapper();

            mapper.Map(request, keyContent);
            keyContent.CreateUserID = iUID;
            keyContent = await KeyManager.EncryptKey(keyContent);

            return(ReturnResult.ResultCalculation(() => KeyContentManager.Update(keyContent)));
        }
Exemplo n.º 2
0
        private void buttonEditKey_Click(object sender, EventArgs e)
        {
            var key = listBoxKeys.GetSelectedItem <IKey>();

            if (key != null)
            {
                EditKey.RaiseEventEx(this, new GenericEventArgs <IKey>(key));
            }
        }