public async Task <IActionResult> DeleteBodyWeight([Required] BodyWeightModel bodyWeightModel)
        {
            var userId = httpContextAccessor.GetUserId();

            var entity = new BodyWeight
            {
                ID         = bodyWeightModel.Id,
                UserId     = userId,
                Weight     = bodyWeightModel.Weight,
                MeasuredOn = bodyWeightModel.MeasuredOn
            };
            await bodyInfoRepository.DeleteBodyWeightAsync(entity);

            return(NoContent());
        }
        public Task AddBodyWeightAsync(BodyWeight bodyWeight)
        {
            if (bodyWeight == null)
            {
                throw new ArgumentNullException(nameof(bodyWeight));
            }

            return(Implementation());

            async Task Implementation()
            {
                await dbContext.BodyWeights.AddAsync(bodyWeight);

                await dbContext.SaveChangesAsync();
            }
        }
        public Task DeleteBodyWeightAsync(BodyWeight bodyWeight)
        {
            if (bodyWeight == null)
            {
                throw new ArgumentNullException(nameof(bodyWeight));
            }

            return(Implementation());

            async Task Implementation()
            {
                var existingEntity = await dbContext.BodyWeights
                                     .SingleOrDefaultAsync(m => m.ID == bodyWeight.ID && m.UserId == bodyWeight.UserId);

                if (existingEntity == null)
                {
                    return;
                }
                dbContext.BodyWeights.Remove(existingEntity);
                await dbContext.SaveChangesAsync();
            }
        }
Exemplo n.º 4
0
        public async Task ProcessAsync(IEvent @event)
        {
            var providerUpdateEvent = (IntegrationProviderUpdateEvent)@event;

            _logger.Information(nameof(FitbitProviderUpdateEventHandler), providerUpdateEvent.Properties);

            FitbitUpdateNotification fitbitUpdate =
                ((JObject)providerUpdateEvent.Data.ProviderData)
                .ToObject <FitbitUpdateNotification>();

            string accessToken = await _fitbitTokenService.GetAccessTokenAsync(providerUpdateEvent.Data.UserId);

            ResourceContainer resource = await _fitbitClient.GetResourceAsync(
                ownerType : fitbitUpdate.OwnerType,
                ownerId : fitbitUpdate.OwnerId,
                collectionType : fitbitUpdate.CollectionType,
                date : fitbitUpdate.Date,
                accessToken : accessToken);

            if (resource.Body is null)
            {
                _logger.LogWarning($"Data mapping not supported: {JsonConvert.SerializeObject(resource)}");
                return;
            }

            await _fhirClient.EnsurePatientDeviceAsync(providerUpdateEvent.Data.UserId);

            IoMTModel iomtModel = new BodyWeight
            {
                Weight = resource.Body.Weight,
                MeasurementDateTime = fitbitUpdate.Date,
                DeviceId            = providerUpdateEvent.Data.UserId,
                PatientId           = providerUpdateEvent.Data.UserId
            };

            await _iomtDataPublisher.PublishAsync(iomtModel);
        }
Exemplo n.º 5
0
 public void AddBodyWeight(BodyWeight weight)
 {
     context.BodyWeights.Add(weight);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Saves the given Weight as BodyWeight to MiData
        /// </summary>
        /// <param name="Weight">The measured weight</param>
        public void SaveWeight(string Weight)
        {
            BodyWeight bw = new BodyWeight(Weight, DateTime.Now);

            App.Midata.SaveWeight(bw);
        }