예제 #1
0
 public async void Create(CollectiveEF collectiveEF)
 {
     using (IDynamoDBContext context = _dbConnection.Context())
     {
         await context.SaveAsync(collectiveEF);
     }
 }
예제 #2
0
        public static CollectiveEF GenerateCollectiveEF(DateTime timeStamp, IList <User> userList)
        {
            float        collectiveEfResult = ComputeCollectiveEFAsync(timeStamp, userList);
            CollectiveEF collectiveEf       = new CollectiveEF()
            {
                Date_taken    = timeStamp,
                Collective_EF = collectiveEfResult
            };

            return(collectiveEf);
        }
        public async Task <IActionResult> Post(DateTime date)
        {
            DateTime dayToCalculate = date.AddDays(-1);

            if (await _collectiveEFRepository.GetById(dayToCalculate) != null)
            {
                return(Conflict("A Collective EF with that date already exists."));
            }

            var users = await _userRepository.GetUsers();

            CollectiveEF collectiveEf = CollectiveEfLogic.GenerateCollectiveEF(dayToCalculate, users);

            _collectiveEFRepository.Create(collectiveEf);
            return(Ok());
        }