コード例 #1
0
ファイル: TypeSystemService.cs プロジェクト: qkxyk/hxcore
        public async Task <BaseResponse> UpdateTypeSystemAsync(int typeId, TypeSystemUpdateDto req, string account)
        {
            var data = await _tsr.FindAsync(req.Id);

            if (data == null)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的类型子系统不存在"
                });
            }
            var sys = await _tsr.Find(a => a.TypeId == typeId && a.Name == req.Name).FirstOrDefaultAsync();

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

                _log.LogInformation($"{account}修改标示为{req.Id}的类型子系统成功");
                return(new BaseResponse {
                    Success = false, Message = "修改类型子系统成功"
                });
            }
            catch (Exception ex)
            {
                _log.LogError($"{account}修改标示为{req.Id}的类型子系统失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}");
                return(new BaseResponse {
                    Success = false, Message = "修改类型子系统失败,请联系管理员"
                });
            }
        }
コード例 #2
0
ファイル: TypeSystemController.cs プロジェクト: qkxyk/hxcore
        public async Task <ActionResult <BaseResponse> > TypeSystemUpdate(int typeId, TypeSystemUpdateDto req)
        {
            //string user = User.Identity.Name;
            //if (string.IsNullOrWhiteSpace(user))
            //{
            //    return Unauthorized("用户凭证缺失");
            //}
            //UserMessage um = JsonConvert.DeserializeObject<UserMessage>(user);
            //string GroupId;
            //bool bRet = _ts.IsExist(a => a.Id == typeId, out GroupId);
            //if (!bRet)
            //{
            //    return new BaseResponse { Success = false, Message = "输入的类型不存在" };
            //}
            //if (!(um.IsAdmin && (um.GroupId == GroupId || um.Code == _config["Group"])))
            //{
            //    return Unauthorized("用户没有权限");
            //}
            string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            var    rm      = await _tss.UpdateTypeSystemAsync(typeId, req, Account);

            return(rm);
        }