Exemplo n.º 1
0
        private async Task SaveData(List <AngleSharp.Dom.IElement> set_Today)
        {
            var today = DateTime.Now.ToUniversalTime().Date;

            //Insert SET
            SET set = new SET()
            {
                Date      = today,
                IndexName = "SET",
                Index     = double.Parse(set_Today[1].TextContent),
            };

            await _mongoUnitOfWork.CreateAsync(collectionName, set).ConfigureAwait(false);

            //Insert SET 50
            set = new SET()
            {
                Date      = today,
                IndexName = "SET50",
                Index     = double.Parse(set_Today[9].TextContent),
            };

            await _mongoUnitOfWork.CreateAsync(collectionName, set).ConfigureAwait(false);

            //Insert SET 100
            set = new SET()
            {
                Date      = today,
                IndexName = "SET100",
                Index     = double.Parse(set_Today[17].TextContent),
            };

            await _mongoUnitOfWork.CreateAsync(collectionName, set).ConfigureAwait(false);
        }
        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);
        }
Exemplo n.º 3
0
        public async Task <SleepInformation> Add(SleepInformation sleepInformation)
        {
            sleepInformation.SleepTime = DateTime.Now.ToUniversalTime();

            return(await _mongoUnitOfWork.CreateAsync(collectionName, sleepInformation).ConfigureAwait(false));
        }