示例#1
0
        public void Visit(Profile visitorProfile, Profile profile)
        {
            if (visitorProfile != null && profile != null && profile.Id != visitorProfile.Id && profile.Guid != visitorProfile.Guid)
            {
                var visit = _visitRepository.SingleAttached(p => p.ProfileId == profile.Id && p.VisitorProfileId == visitorProfile.Id);

                if (visit == null)
                {
                    _visitRepository.Add(new Visit {
                        ProfileId = profile.Id, VisitorProfileId = visitorProfile.Id, VisitCount = 1
                    });
                }
                else
                {
                    visit.VisitCount++;
                    _visitRepository.FullUpdate(visit);
                }

                //TODO: Modify this with PATCH method of Raven Repository. http://ravendb.net/docs/client-api/partial-document-updates
                //_visitRepositoryRaven.Add(new Visit { ProfileId = profile.Id, VisitorProfileId = visitorProfile.Id, VisitCount = visit.VisitCount });

                var visitRaven = _visitRepositoryRaven.SingleAttached(p => p.ProfileId == profile.Id && p.VisitorProfileId == visitorProfile.Id);
                if (visitRaven == null)
                {
                    _visitRepositoryRaven.Add(new Visit {
                        ProfileId = profile.Id, VisitorProfileId = visitorProfile.Id, VisitCount = 1
                    });
                }
                else
                {
                    visitRaven.VisitCount++;
                    _visitRepositoryRaven.FullUpdate(visitRaven);
                }
            }
        }