예제 #1
0
        public async Task <BaseResponse> UpdateDeviceCardAsync(string account, DeviceCardUpdateDto req, string DeviceSn)
        {
            var d = await _dcr.Find(a => a.DeviceSn == DeviceSn).FirstOrDefaultAsync();

            if (d == null)
            {
                return(new BaseResponse {
                    Success = false, Message = "该设备没有添加相关的数据,请添加"
                });
            }
            //检查该设备是否已存在相同的流量卡
            var card = await _dcr.Find(a => a.CardNo == req.CardNo && a.DeviceSn != DeviceSn).CountAsync();

            if (card > 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的卡号已被占用,请确认"
                });
            }
            try
            {
                var entity = _mapper.Map(req, d);
                entity.Modify     = account;
                entity.ModifyTime = DateTime.Now;
                await _dcr.SaveAsync(entity);

                _log.LogInformation($"{account}修改标示为{req.CardNo}的流量卡信息成功");
                return(new BaseResponse {
                    Success = true, Message = "修改数据成功"
                });
            }
            catch (Exception ex)
            {
                _log.LogError($"{account}修改流量卡失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}");
                return(new BaseResponse {
                    Success = false, Message = "修改流量卡失败,请联系管理员"
                });
            }
        }
예제 #2
0
        public async Task <ActionResult <BaseResponse> > UpdateDeviceCard(string GroupId, string DeviceSn, [FromBody] DeviceCardUpdateDto req)
        {
            var account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            var rm      = await _dcs.UpdateDeviceCardAsync(account, req, DeviceSn);

            return(rm);
        }