Exemplo n.º 1
0
        public async Task UpdateUserLocation(
            IUserLocation userLocation,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            ThrowIfDisposed();
            cancellationToken.ThrowIfCancellationRequested();

            if (userLocation == null)
            {
                throw new ArgumentException("userLocation must not be null");
            }
            if (userLocation.Id == Guid.Empty)
            {
                throw new ArgumentException("Id must not be empty guid");
            }
            if (userLocation.UserId == Guid.Empty)
            {
                throw new ArgumentException("UserId must not be empty guid");
            }
            if (userLocation.SiteId == Guid.Empty)
            {
                throw new ArgumentException("SiteId must not be empty guid");
            }

            //await EnsureProjectId().ConfigureAwait(false);
            var projectId = userLocation.SiteId.ToString();

            var ul = UserLocation.FromIUserLocation(userLocation);

            await _locationCommands.UpdateAsync(
                projectId,
                ul.Id.ToString(),
                ul,
                cancellationToken).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task AddUserLocation(
            IUserLocation userLocation,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            ThrowIfDisposed();
            cancellationToken.ThrowIfCancellationRequested();

            if (userLocation == null)
            {
                throw new ArgumentException("userLocation can't be null");
            }

            var ul = UserLocation.FromIUserLocation(userLocation);

            if (ul.Id == Guid.Empty)
            {
                ul.Id = Guid.NewGuid();
            }

            dbContext.UserLocations.Add(ul);

            int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken);
        }