示例#1
0
        public async Task <ActionResult <CalorieIntakeDto> > Replace(CalorieIntakeCreationDto calorieIntakeCreationDto, string id)
        {
            var na = new CalorieIntake(ObjectId.Parse(id), calorieIntakeCreationDto.CalorieGoal, calorieIntakeCreationDto.CalorieCurrent, calorieIntakeCreationDto.FatGoal, calorieIntakeCreationDto.FatCurrent, calorieIntakeCreationDto.ProteinGoal, calorieIntakeCreationDto.ProteinCurrent, calorieIntakeCreationDto.CarbohydratesGoal, calorieIntakeCreationDto.CarbohydratesCurrent, calorieIntakeCreationDto.Date);
            await calorieIntakeCollection.ReplaceById(id, na);

            return(Ok(200));
        }
示例#2
0
        public async Task <ActionResult <CalorieIntakeDto> > Add(CalorieIntakeCreationDto calorieIntakeCreationDto)
        {
            var na = new CalorieIntake(ObjectId.Empty, calorieIntakeCreationDto.CalorieGoal, calorieIntakeCreationDto.CalorieCurrent, calorieIntakeCreationDto.FatGoal, calorieIntakeCreationDto.FatCurrent, calorieIntakeCreationDto.ProteinGoal, calorieIntakeCreationDto.ProteinCurrent, calorieIntakeCreationDto.CarbohydratesGoal, calorieIntakeCreationDto.CarbohydratesCurrent, calorieIntakeCreationDto.Date);
            await calorieIntakeCollection.InsertOneAsync(na);

            return(CreatedAtRoute(nameof(GetSingleCalorieIntake), new { na.Id },
                                  new CalorieIntakeDto(na.Id.ToString(), na.CalorieGoal, na.CalorieCurrent, na.FatGoal, na.FatCurrent, na.ProteinGoal, na.ProteinCurrent, na.CarbohydratesGoal, na.CarbohydratesCurrent, na.Date)));
        }