public MemberChangeContext UpdateMemberFields(Member member, responseUser memberData) { if (memberData == null) { return(null); } MemberChangeContext changeContext = new MemberChangeContext(); Member newInstance = new Member() { VkGroupId = member.VkGroupId, VkMemberId = member.VkMemberId }; newInstance.Name = this.GetMemberName(memberData); newInstance.Gender = this.GetGender(memberData.sex); this.AssignBirthDate(newInstance, memberData.bdate); newInstance.CityId = string.IsNullOrWhiteSpace(memberData.city) ? 0 : int.Parse(memberData.city); newInstance.CountryId = string.IsNullOrWhiteSpace(memberData.country) ? 0 : int.Parse(memberData.country); newInstance.Education = this.GetMemberEducation(memberData); newInstance.MaritalStatus = this.GetMaritalStatus(memberData.relation); newInstance.Status = this.GetMemberStatus(memberData); changeContext.IsMemberChanged = this.UpdateMemberInfo(member, newInstance); changeContext.IsMemberInterestsChanged = this.UpdateMemberInterests(member, memberData); return(changeContext); }
private void UpdateExistingMember(Member savedMember, responseUser memberData) { this.log.DebugFormat("Member with VkId={0} is already in database", memberData.uid); MemberChangeContext context = this.memberMapper.UpdateMemberFields(savedMember, memberData); savedMember.IsDeleted = false; this.memberRepository.UpdateMember(savedMember, context); }
public void UpdateMember(Member member, MemberChangeContext context = null) { if (member == null) { return; } MemberChangeContext changeContext = context ?? MemberChangeContext.Default; using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway()) { if (changeContext.IsMemberChanged) { dataGateway.Connection.Execute(@"update member set vkgroupid = @VkGroupId, name = @Name, gender = @Gender, maritalstatus = @MaritalStatus, birthday = @BirthDay, birthmonth = @BirthMonth, birthyear = @BirthYear, cityid = @CityId, countryid = @CountryId, education = @Education, vkmemberid = @VkMemberId, status = @Status, isdeleted = @IsDeleted where id = @Id", this.Flatten(member)); } var update = new MemberUpdate { VkMemberId = member.VkMemberId, VkGroupId = member.VkGroupId, CreatedDate = DateTime.UtcNow, IsNew = false }; update.Id = dataGateway.Connection.Query <int>(@"INSERT INTO memberupdate(vkgroupid, vkmemberid, createddate, isnew) VALUES (@vkGroupId, @vkMemberId, @createdDate, @isNew) RETURNING id", update).First(); if (!changeContext.IsMemberInterestsChanged) { return; } if (member.Interests != null && member.Interests.Count > 0) { foreach (var interest in member.Interests) { if (interest.IsTransient()) { this.InsertInterest(interest, dataGateway); } else { this.UpdateInterest(interest, dataGateway); } } } } }
public void UpdateMember(Member member, MemberChangeContext changeContext = null) { this.membersRepository.UpdateMember(member, changeContext); this.cachingStrategy.StoreItem(member); }