예제 #1
0
        public async Task InsertBatchAsync(byte batchStatus, Guid guid, int totalBatchItems)
        {
            var dto = new BatchDto()
            {
                StatusId        = batchStatus,
                Guid            = guid,
                CreatedAt       = DateTime.UtcNow,
                TotalBatchItems = totalBatchItems
            };

            await _db.Batch.AddAsync(dto);

            await _db.SaveChangesAsync();
        }
예제 #2
0
        public async Task MergeIPDetailsAsync(IEnumerable <IPDetailsDto> ipDetailsDtos)
        {
            foreach (var dto in ipDetailsDtos)
            {
                if (!await _db.IPDetail.AnyAsync(i => i.Ip == dto.Ip))
                {
                    await InsertIPDetailsAsync(dto);
                }
                else
                {
                    var ipDetails = await _db.IPDetail.FirstAsync(d => d.Ip == dto.Ip);

                    ipDetails.City      = dto.City;
                    ipDetails.Country   = dto.Country;
                    ipDetails.Continent = dto.Continent;
                    ipDetails.Longitude = dto.Longitude;
                    ipDetails.Latitude  = dto.Latitude;
                    _db.IPDetail.Update(ipDetails);
                }
            }
            await _db.SaveChangesAsync();
        }