예제 #1
0
        public async Task <ActionResult <BaseResponse> > Update(int typeId, TypeConfigUpdateViewModel req)
        {
            string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            var    rm      = await _tc.UpdateAsync(req, Account);

            return(rm);
        }
예제 #2
0
        public async Task <BaseResponse> UpdateAsync(TypeConfigUpdateViewModel req, string account)
        {
            var data = await _tc.FindAsync(req.Id);

            if (data == null)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型配置不存在"
                });
            }
            var ret = await _tc.Find(a => a.DataName == req.DataName && a.TypeId == data.TypeId).FirstOrDefaultAsync();

            if (ret != null && ret.Id != req.Id)
            {
                return(new BaseResponse {
                    Success = false, Message = "已存在相同名称的类型配置"
                });
            }
            try
            {
                var entity = _mapper.Map(req, data);
                entity.Modify     = account;
                entity.ModifyTime = DateTime.Now;
                await _tc.SaveAsync(entity);

                _log.LogInformation($"{account}修改标示为{req.Id}的类型配置数据成功");
                return(new BaseResponse {
                    Success = true, Message = "修改类型配置数据成功"
                });
            }
            catch (Exception ex)
            {
                _log.LogError($"{account}修改标示为{req.Id}的类型配置数据失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}");
                return(new BaseResponse {
                    Success = false, Message = "修改类型配置数据失败"
                });
            }
        }