コード例 #1
0
        public IActionResult AddInterest(string userId, int interestId, string type)
        {
            if (type == "TravelAndLife")
            {
                var userTravelInterest = new UserTravelInterest
                {
                    UserId           = userId,
                    TravelInterestId = interestId
                };

                userTravelInterestRepository.Create(userTravelInterest);
                return(Ok());
            }
            else if (type == "HealthAndWellness")
            {
                var userHealthInterest = new UserHealthInterest
                {
                    UserId           = userId,
                    HealthInterestId = interestId
                };

                userHealthInterestRepository.Create(userHealthInterest);
                return(Ok());
            }
            else if (type == "FoodAndDrink")
            {
                var userFoodInterest = new UserFoodInterest
                {
                    UserId         = userId,
                    FoodInterestId = interestId
                };

                userFoodInterestRepository.Create(userFoodInterest);
                return(Ok());
            }

            return(StatusCode(500));
        }
コード例 #2
0
 public void Create(UserHealthInterest userHealthInterest)
 {
     context.UserHealthInterests.Add(userHealthInterest);
     context.SaveChanges();
 }