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); } }
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); }
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); }