Example #1
0
        public void AddUserProductsRang(CreateUserProductsModel userProductsModel)
        {
            var products    = this.productRepository.GetAll().Where(s => userProductsModel.ProductsIds.Contains(s.Id)).ToList();
            var currentUser = this.userRepository.Get(userProductsModel.UserId);
            List <Domain.UserProducts.UserProducts> UserProductsList = new List <Domain.UserProducts.UserProducts>();

            foreach (var itemProduct in products)
            {
                UserProductsList.Add(this.userProductsFactory.Create(currentUser, itemProduct));
            }
            this.userProductRepository.AddRand(UserProductsList);
        }
 public IActionResult SubmitUserProducts([FromQuery] int userId, [FromBody] List <int> productIds)
 {
     try
     {
         CreateUserProductsModel userProductModel = new CreateUserProductsModel(userId, productIds);
         _userProductsRepositoryFacade.AddUserProductsRang(userProductModel);
         return(Ok());
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }