Exemple #1
0
        public async Task <ActionResult> Consume([FromBody] ConsumeProductCommand command)
        {
            if (command.UserId > 0)
            {
                Core.Models.User user = await _usersProvider.FindUserById(command.UserId);

                user.RecordConsumption(command.CarbAmount);

                return(NotModified());
            }

            return(NotFound());
        }
Exemple #2
0
        public async Task <ActionResult> Consume([FromBody] ConsumeProductCommand command)
        {
            if (command.UserId > 0)
            {
                var user = InMemoryUsers.GetUsers().FirstOrDefault(x => x.Id == command.UserId);
                user.CarbConsumption.Add(new CarbConsumption()
                {
                    Amount     = command.CarbAmount,
                    ConsumedOn = DateTimeOffset.Now
                });

                return(NotModified());
            }
            else
            {
                return(NotFound());
            }
        }