Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using(TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {IsolationLevel = IsolationLevel.RepeatableRead}))
- {
- PersonDayStatisticsUnit pdsu = db.PersonDayStatisticsUnits.FirstOrDefault(x => x.UnitId == su.Id && x.Date == now && x.PersonAnonimousGuid == personGuid);
- if (pdsu == null)
- {
- pdsu = new PersonDayStatisticsUnit()
- {
- UnitId = su.Id,
- Count = 1,
- Date = now,
- PersonAnonimousGuid = personGuid
- };
- db.PersonDayStatisticsUnits.Add(pdsu);
- ret = true;
- }
- else
- {
- pdsu.Count++;
- ret = false;
- }
- db.SaveChanges();
- scope.Complete();
- }
Add Comment
Please, Sign In to add comment