Beispiel #1
0
 public ActionResult GetAllReviews()
 {
     try
     {
         var productList = MH.GetListOfObjects(null, null, null, null, null, null, "ProductDB", "Product").Result;
         if (productList != null)
         {
             List <ReviewsForEachProduct> reviewsList = new List <ReviewsForEachProduct>();
             foreach (var product in productList)
             {
                 var productData = BsonSerializer.Deserialize <Product>(product);
                 reviewsList.Add(new ReviewsForEachProduct {
                     ProductSKU = productData.ProductSKU, ProductReviews = productData.ProductReviews
                 });
             }
             return(Ok(new ResponseData
             {
                 Code = "200",
                 Message = "Success",
                 Data = reviewsList
             }));
         }
         else
         {
             return(BadRequest(new ResponseData
             {
                 Code = "404",
                 Message = "No products found"
             }));
         }
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("ProductController", "GetAllReviews", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }
 public ActionResult GetAllCoupon()
 {
     try
     {
         var getCoupons = MH.GetListOfObjects(null, null, null, null, null, null, "CouponDB", "Coupon").Result;
         if (getCoupons != null)
         {
             List <Coupon> couponList = new List <Coupon>();
             foreach (var coupon in getCoupons)
             {
                 couponList.Add(BsonSerializer.Deserialize <Coupon>(coupon));
             }
             return(Ok(new ResponseData
             {
                 Code = "200",
                 Message = "Success",
                 Data = couponList
             }));
         }
         else
         {
             return(Ok(new ResponseData
             {
                 Code = "404",
                 Message = "No coupons found",
                 Data = null
             }));
         }
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("CouponController", "GetAllCoupon", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }