コード例 #1
0
 public IActionResult AddUserProduct(UserProduct userProduct)
 {
     try
     {
         //var newUserProduct = new UserProduct()
         //{
         //    userId = userProduct.userId,
         //    productId = userProduct.productId,
         //    quantity = userProduct.quantity
         //};
         userProductService.AddUserProduct(userProduct);
         return(CreatedAtAction("AddUserProduct", userProduct));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
コード例 #2
0
 public ActionResult AddUserProduct(Users userid, List <Products> productid)
 {
     //seçilen kullanıcı ve ürünleri database kaydetmek için çağrışan işlemler
     try
     {
         UserProduct userProduct = new UserProduct();
         userProduct.UserId = userid.UserId;
         foreach (var items in productid)
         {
             userProduct.ProductId = items.ProductId;
             _userProductService.AddUserProduct(userProduct);
         }
         return(Json(true));
     }
     catch (InvalidCastException e)
     {
         return(Json(false));
     }
 }