コード例 #1
0
        public override void Update(UserDto entityDto)
        {
            var dbUser = this.GetSingle(it => it.UserId == entityDto.UserId);

            if (dbUser != null)
            {
                if (dbUser.NationalNo != entityDto.NationalNo)
                {
                    SecurityCompanyTDataAccess companayDa = new SecurityCompanyTDataAccess();
                    var company = companayDa.GetSingle(it => it.NationalNo == entityDto.NationalNo);
                    if (company != null)
                    {
                        UserToCompanyTDataAccess userToCompDa = new UserToCompanyTDataAccess();
                        var userToCompanyDb            = userToCompDa.GetSingle(it => it.ToDate == null && it.SecurityUserId == entityDto.UserId);
                        UserToCompanyDto userToCompany = new UserToCompanyDto()
                        {
                            CompanyId      = company.CompanyId,
                            SecurityUserId = entityDto.UserId,
                            FromDate       = DateTime.Now
                        };
                        userToCompanyDb.ToDate = DateTime.Now;
                        userToCompDa.Insert(userToCompany);
                        userToCompDa.Update(userToCompany);
                    }
                }
                base.Update(entityDto);
            }
        }
コード例 #2
0
        public override void Insert(ISE.SM.Common.DTO.UserDto entityDto)
        {
            SecurityCompanyTDataAccess companayDa = new SecurityCompanyTDataAccess();

            var company = companayDa.GetSingle(it => it.NationalNo == entityDto.NationalNo);

            if (company != null)
            {
                UserToCompanyTDataAccess userToCompDa  = new UserToCompanyTDataAccess();
                UserToCompanyDto         userToCompany = new UserToCompanyDto()
                {
                    CompanyId      = company.CompanyId,
                    SecurityUserId = entityDto.UserId,
                    FromDate       = DateTime.Now
                };
                userToCompDa.Insert(userToCompany);
            }

            base.Insert(entityDto);
        }
コード例 #3
0
        public override void Insert(List <UserDto> entityDtoList)
        {
            SecurityCompanyTDataAccess companayDa = new SecurityCompanyTDataAccess();

            foreach (var entityDto in entityDtoList)
            {
                var company = companayDa.GetSingle(it => it.NationalNo == entityDto.NationalNo);
                if (company != null)
                {
                    UserToCompanyTDataAccess userToCompDa  = new UserToCompanyTDataAccess();
                    UserToCompanyDto         userToCompany = new UserToCompanyDto()
                    {
                        CompanyId      = company.CompanyId,
                        SecurityUserId = entityDto.UserId,
                        FromDate       = DateTime.Now
                    };
                    userToCompDa.Insert(userToCompany);
                }
            }
            base.Insert(entityDtoList);
        }