Example #1
0
        public UserInfoForEditOutput SetUserInfo(ExtendInfoEditDto input)
        {
            var entity = Mapper.Map <ExtendInfo>(input);
            var userID = entity.EnityID;

            #region 添加Info表信息
            //var extendInfo = _extendRepository.BindToInfo(entity, EntityTypeName, userID);
            entity.EntityTypeFullName = EntityTypeName;
            entity.Id = null;
            if (entity != null)
            {
                //_entityRepository.Insert(entity);
                var extendInfo = _extendInfoManager.InsertToInfo(entity);
                var indexInfo  = extendInfo.Id;
                CurrentUnitOfWork.SaveChanges();
                //return AutoMapper.Mapper.Map<ExtendInfoEditDto>(input);
            }
            #endregion
            //var user = _userManager.GetUserByIdAsync(userID);
            var extendInfos = _extendRepository.GetAll()
                              .Where(t => t.EnityID == userID &&
                                     t.EntityTypeFullName == EntityTypeName);

            var user = Repository.GetAllIncluding(x => x.Roles).FirstOrDefault(x => x.Id == userID);
            //var userEditDto = ObjectMapper.Map<UserInfoDto>(user);
            return(new UserInfoForEditOutput
            {  //User = Mapper.Map<UserDto>(user),
                User = toInfo(user),
                ExtendInfos = Mapper.Map <List <ExtendInfoDto> >(extendInfos).ToList()
            });
        }
Example #2
0
        public List <ExtendInfoDto> SetUserInfo2(ExtendInfoEditDto input)
        {
            var entity = Mapper.Map <ExtendInfo>(input);
            var userID = entity.EnityID;

            //var extendInfo = _extendRepository.BindToInfo(entity, EntityTypeName, userID);
            entity.EntityTypeFullName = EntityTypeName;
            entity.Id = null;
            if (entity != null)
            {
                //_entityRepository.Insert(entity);

                var extendInfo = _extendRepository.InsertAndGetId(entity);

                CurrentUnitOfWork.SaveChanges();

                var extendInfos = _extendInfoManager.GetAllInfo()
                                  .Where(t => t.EnityID == userID &&
                                         t.EntityTypeFullName == EntityTypeName);

                return(Mapper.Map <List <ExtendInfoDto> >(extendInfos).ToList());
                //return AutoMapper.Mapper.Map<ExtendInfoEditDto>(input);
            }
            return(null);
        }
        /// <summary>
        /// 编辑ExtendInfo
        /// </summary>

        protected virtual async Task Update(ExtendInfoEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新

            //var entity = await _entityRepository.GetAsync(input.Id.Value);
            //input.MapTo(entity);

            // ObjectMapper.Map(input, entity);
            await _entityRepository.UpdateAsync(AutoMapper.Mapper.Map <ExtendInfo>(input));
        }
        /// <summary>
        /// 新增ExtendInfo
        /// </summary>



        public ExtendInfoEditDto InsertToInfo(ExtendInfoEditDto input)
        {
            var entity = AutoMapper.Mapper.Map <ExtendInfo>(input);

            entity.Id = null;
            if (entity != null)
            {
                _entityRepository.Insert(entity);

                CurrentUnitOfWork.SaveChanges();
                return(AutoMapper.Mapper.Map <ExtendInfoEditDto>(input));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        public async Task <UserInfoForEditOutput> SetUserInfo3(ExtendInfoEditDto input)
        {
            var user6 = await _userManager.GetUserByIdAsync(input.id);

            //MapToEntity(input, user);

            //CheckErrors(await _userManager.UpdateAsync(user));

            //if (input.RoleNames != null)
            //{
            //    CheckErrors(await _userManager.SetRoles(user, input.RoleNames));
            //}
            var entity = Mapper.Map <ExtendInfo>(input);
            var userID = entity.EnityID;

            #region MyRegion
            //var extendInfo = _extendRepository.BindToInfo(entity, EntityTypeName, userID);
            entity.EntityTypeFullName = EntityTypeName;
            entity.Id = null;
            if (entity != null)
            {
                var extendInfo = _extendInfoManager.InsertToInfo(entity);
                CurrentUnitOfWork.SaveChanges();
            }
            #endregion
            var user        = _userManager.GetUserByIdAsync(userID);
            var extendInfos = _extendRepository.GetAll()
                              .Where(t => t.EnityID == userID &&
                                     t.EntityTypeFullName == EntityTypeName);


            var user2 = Repository.GetAllIncluding(x => x.Roles).FirstOrDefaultAsync(x => x.Id == userID);


            //var userEditDto = ObjectMapper.Map<UserInfoDto>(user);
            return(new UserInfoForEditOutput
            {
                //User = Mapper.Map<UserDto>(user),
                User = Mapper.Map <UserInfoDto>(user2),
                ExtendInfos = Mapper.Map <List <ExtendInfoDto> >(extendInfos).ToList()
            });
            //return Task<UserInfoForEditOutput>(a);
        }
        protected virtual async Task <ExtendInfoEditDto> Create(ExtendInfoEditDto input)
        {
            ////TODO:新增前的逻辑判断,是否允许新增

            //         // var entity = ObjectMapper.Map <ExtendInfo>(input);
            //         var entity=input.MapTo<ExtendInfo>();


            //entity = await _entityRepository.InsertAsync(entity);
            //return entity.MapTo<ExtendInfoEditDto>();


            var task = AutoMapper.Mapper.Map <ExtendInfo>(input);

            var entity = _entityRepository.Insert(task);

            CurrentUnitOfWork.SaveChanges();
            return(AutoMapper.Mapper.Map <ExtendInfoEditDto>(input));
        }
        /// <summary>
        /// 获取编辑 ExtendInfo
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>

        public async Task <GetExtendInfoForEditOutput> GetForEdit(NullableIdDto <long> input)
        {
            var output = new GetExtendInfoForEditOutput();
            ExtendInfoEditDto editDto;

            if (input.Id.HasValue)
            {
                var entity = await _entityRepository.GetAsync(input.Id.Value);

                editDto = entity.MapTo <ExtendInfoEditDto>();

                //extendInfoEditDto = ObjectMapper.Map<List<extendInfoEditDto>>(entity);
            }
            else
            {
                editDto = new ExtendInfoEditDto();
            }

            output.ExtendInfo = editDto;
            return(output);
        }
 public ExtendInfoEditDto UpdateInfo(ExtendInfoEditDto input)
 {
     //TODO:更新前的逻辑判断,是否允许更新
     _entityRepository.Update(AutoMapper.Mapper.Map <ExtendInfo>(input));
     return(input);
 }