Ejemplo n.º 1
0
        //public ActionResult AddNew([Bind(Include = "OverallRating,Title,Content")] ReviewProduction1 model)
        public async Task <ActionResult> AddNewReview(ReviewProduction model)
        {
            if (UserManager.User != null)
            {
                if (ModelState.IsValid)
                {
                    ProductionService service = new ProductionService();

                    // add new review of a product
                    model.UserId = UserManager.User.Id;
                    await service.addReview(model);

                    /*{
                     *  ReviewId,
                     *  Title,
                     *  Content,
                     *  OverallRating,
                     *  UserName,
                     *  ReviewDate,
                     * }*/
                    // get all reviews of a product
                    List <ReviewProduction> reviewList = await service.getReviewsByProductId(model.ProductId);

                    return(PartialView("_PartialPage_ReviewList", reviewList));
                }

                return(this.Json(new
                {
                    ResponseType = Config.SOMETHING_WRONG_WITH_POST_REQUEST,
                    Msg = "Something goes wrong, please try again later"
                }));
            }

            return(this.Json(new
            {
                ResponseType = Config.NEED_LOGIN,
                Msg = "Please login first"
            }));
        }