public async Task <BrushingInformation> ManageInformation(BrushingInformation brushingInformation)
        {
            brushingInformation.BrushingDate = DateTime.Now.ToUniversalTime().Date;

            var data = await _mongoUnitOfWork
                       .GetAsync <BrushingInformation>(collectionName, x => x.UserId == brushingInformation.UserId && x.BrushingDate == brushingInformation.BrushingDate)
                       .ConfigureAwait(false);

            if (data != null)
            {
                if (data.BrushingRemain > 0)
                {
                    data.BrushingRemain -= 1;
                }

                await _mongoUnitOfWork.UpdateAsync(collectionName, x => x.Id == data.Id, data).ConfigureAwait(false);
            }
            else
            {
                brushingInformation.BrushingRemain = brushingInformation.BrushingSet - 1;
                data = await _mongoUnitOfWork.CreateAsync(collectionName, brushingInformation).ConfigureAwait(false);
            }
            return(data);
        }
예제 #2
0
 public async Task Update(SleepInformation sleepInformation)
 {
     await _mongoUnitOfWork.UpdateAsync(collectionName, x => x.Id == sleepInformation.Id, sleepInformation).ConfigureAwait(false);
 }