예제 #1
0
        public HttpResponseMessage Post(ReviewData data)
        {
            string cli   = data.CodCliente;
            string art   = data.CodArtigo;
            string text  = data.text;
            int    score = data.score;

            Debug.Write("\n" + cli + ";" + art + ";" + text + ";" + score.ToString() + "\n");

            if (art != null && cli != null)
            {
                if (insertOrUpdReview(cli, art, text, score) == 0)
                {
                    var response = Request.CreateResponse(
                        HttpStatusCode.OK);

                    return(response);
                }
                else
                {
                    // if email or password is null, immediately send bad request
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            else
            {
                // if email or password is null, immediately send bad request
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
예제 #2
0
        public override IReview CreateReview()
        {
            reviews.Move();
            ReviewData rv = reviews.Current();

            return(new PolandReview(new Review(rv.UserName, rv.Review)));
        }
예제 #3
0
    void DisplayReview(int id, string text, bool isGood)
    {
        switch (currentStatus)
        {
        // Display the review
        case ReviewStatus.closed:
        case ReviewStatus.closing:
            nextReview = new ReviewData()
            {
                isGoodReview = isGood, reviewId = id, reviewText = text
            };
            break;

        // One is still coming in, do nothing
        case ReviewStatus.revealing:
            break;

        // Player missed it. Close up
        case ReviewStatus.showing:
            CloseReview(currentReview.isGoodReview, null);
            nextReview = new ReviewData()
            {
                isGoodReview = isGood, reviewId = id, reviewText = text
            };
            break;
        }
    }
예제 #4
0
        internal IFacadeUpdateResult <ReviewData> SaveReview(ReviewData dto, object refId)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <ReviewData> result = new FacadeUpdateResult <ReviewData>();
            IReviewService service  = UnitOfWork.GetService <IReviewService>();
            Review         instance = RetrieveOrNew <ReviewData, Review, IReviewService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.ReferenceId   = refId;
                instance.Title         = dto.Title;
                instance.Content       = dto.Content;
                instance.IssuedBy      = dto.IssuedBy;
                instance.IssuedByEmail = dto.IssuedByEmail;
                instance.IsPublished   = dto.IsPublished;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <ReviewData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
예제 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReviewData reviewData = db.ReviewDatas.Find(id);

            db.ReviewDatas.Remove(reviewData);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #6
0
        public ReviewDto Create()
        {
            var data = new ReviewData();

            data.ReviewId = Guid.NewGuid();
            MockDb.Reviews.Add(data);
            return(CreateDtoFromData(data));
        }
예제 #7
0
 private void AnimateOpening()
 {
     if (currentStatus == ReviewStatus.closed)
     {
         currentReview = nextReview;
         nextReview    = null;
         StartCoroutine(AnimateOpeningCo(currentReview.reviewText));
     }
 }
예제 #8
0
 public static ReviewDto CreateDtoFromData(ReviewData data)
 {
     return(new ReviewDto()
     {
         Id = data.ReviewId,
         Rating = data.Rating,
         Comments = data.Comments,
         CustomerId = data.CustomerId
     });
 }
예제 #9
0
 public ActionResult Edit([Bind(Include = "ReviewDataID,ReviewID,ReviewElementID")] ReviewData reviewData)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reviewData).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ReviewID        = new SelectList(db.Reviews, "ReviewID", "ReviewID", reviewData.ReviewID);
     ViewBag.ReviewElementID = new SelectList(db.ReviewElements, "ReviewElementID", "Title", reviewData.ReviewElementID);
     return(View(reviewData));
 }
예제 #10
0
        public ActionResult Create([Bind(Include = "ReviewDataID,ReviewID,ReviewElementID")] ReviewData reviewData)
        {
            if (ModelState.IsValid)
            {
                db.ReviewDatas.Add(reviewData);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ReviewID        = new SelectList(db.Reviews, "ReviewID", "ReviewID", reviewData.ReviewID);
            ViewBag.ReviewElementID = new SelectList(db.ReviewElements, "ReviewElementID", "Title", reviewData.ReviewElementID);
            return(View(reviewData));
        }
예제 #11
0
        // GET: /ReviewData/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReviewData reviewData = db.ReviewDatas.Find(id);

            if (reviewData == null)
            {
                return(HttpNotFound());
            }
            return(View(reviewData));
        }
예제 #12
0
        public IFacadeUpdateResult <ReviewData> SaveReview(ReviewData dto, object refId)
        {
            UnitOfWork.BeginTransaction();
            IFacadeUpdateResult <ReviewData> result = ReviewSystem.SaveReview(dto, refId);

            if (result.IsSuccessful)
            {
                UnitOfWork.CommitTransaction();
            }
            else
            {
                UnitOfWork.RollbackTransaction();
            }
            return(result);
        }
예제 #13
0
        // GET: /ReviewData/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReviewData reviewData = db.ReviewDatas.Find(id);

            if (reviewData == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ReviewID        = new SelectList(db.Reviews, "ReviewID", "ReviewID", reviewData.ReviewID);
            ViewBag.ReviewElementID = new SelectList(db.ReviewElements, "ReviewElementID", "Title", reviewData.ReviewElementID);
            return(View(reviewData));
        }
예제 #14
0
        public async Task <IActionResult> Index(int deckId)
        {
            long numberOfCardInstancesToReview = await GetNumberOfCardInstancesToReview(deckId);

            if (numberOfCardInstancesToReview > 0)
            {
                ViewData["Title"] = "Review";

                var reviewData = new ReviewData();
                reviewData.DeckId = deckId;

                return(View(reviewData));
            }
            else
            {
                return(RedirectToAction("", "Deck",
                                        new { deckId = deckId }));
            }
        }
예제 #15
0
        public void SaveReview()
        {
            // Mock data
            ReviewDto dto = new ReviewDto();

            dto.Title         = "test1";
            dto.Content       = "review 1 content";
            dto.IssuedBy      = "david";
            dto.IssuedByEmail = "*****@*****.**";
            dto.IsPublished   = true;

            ReviewData   data   = ReviewConverter.ConvertToData(dto);
            ReviewFacade facade = new ReviewFacade(UnitOfWork);
            IFacadeUpdateResult <ReviewData> result = facade.SaveReview(data, 0);

            if (result.IsSuccessful)
            {
            }
        }
예제 #16
0
        private static List <ReviewData> GerReviews(XmlNode bookNode, string xPathQuery)
        {
            List <ReviewData> reviewsData = new List <ReviewData>();

            XmlNodeList reviewsList = bookNode.SelectNodes(xPathQuery);

            foreach (XmlNode reviewNode in reviewsList)
            {
                string reviewText = reviewNode.InnerText.Trim();

                var    reviewAuthorAttribute = reviewNode.Attributes["author"];
                string reviewAuthor          = null;
                if (reviewAuthorAttribute != null)
                {
                    reviewAuthor = reviewAuthorAttribute.InnerText.Trim();
                }

                var      reviewCreationDateAttribute = reviewNode.Attributes["date"];
                DateTime reviewCreationDate          = DateTime.Now;
                if (reviewCreationDateAttribute != null)
                {
                    CultureInfo provider = CultureInfo.InvariantCulture;
                    string      reviewCreationDateString = reviewCreationDateAttribute.InnerText;
                    reviewCreationDate = DateTime.ParseExact(reviewCreationDateString, "d-MMM-yyyy", provider);
                }

                ReviewData reviewData = new ReviewData()
                {
                    CreationDate = reviewCreationDate,
                    Text         = reviewText,
                    AuthorName   = reviewAuthor
                };

                reviewsData.Add(reviewData);
            }

            return(reviewsData);
        }
예제 #17
0
        public ReviewDto Update(ReviewDto dto)
        {
            ReviewData data    = null;
            var        results = from r in MockDb.Reviews
                                 where r.ReviewId == dto.Id
                                 select r;

            if (results.Count() == 1)
            {
                data = results.First();
                MockDb.Reviews.Remove(data);
            }
            else
            {
                data = new ReviewData();
            }
            data.ReviewId   = dto.Id;
            data.Rating     = dto.Rating;
            data.Comments   = dto.Comments;
            data.CustomerId = dto.CustomerId;

            MockDb.Reviews.Add(data);
            return(dto);
        }
예제 #18
0
 public ReviewBusiness(BookStoreContext context)
 {
     _reviewData = new ReviewData(context);
 }
        public async Task <ActionResult> PostReview(ReviewData review)
        {
            string customerId = User.FindFirst(ClaimTypes.NameIdentifier).Value;


            // Add the review to the database
            unitOfWork.ProductReviews.Add(new ProductReview
            {
                ProductId  = review.ProductId,
                CustomerId = customerId,
                Title      = review.Title,
                Rating     = review.Rating,
                Date       = DateTime.Now,
                Text       = review.Text
            });


            // Get the product that is associated with this review
            Product product = await unitOfWork.Products.Get(review.ProductId);

            // Increment the star based on the rating. So if the rating is 3, the threeStars property will be incremented
            switch (review.Rating)
            {
            case 1:
                product.OneStar++;
                break;

            case 2:
                product.TwoStars++;
                break;

            case 3:
                product.ThreeStars++;
                break;

            case 4:
                product.FourStars++;
                break;

            case 5:
                product.FiveStars++;
                break;
            }

            // Increment total reviews
            product.TotalReviews++;

            // Calculate the product's rating
            double sum = (5 * product.FiveStars) +
                         (4 * product.FourStars) +
                         (3 * product.ThreeStars) +
                         (2 * product.TwoStars) +
                         (1 * product.OneStar);

            product.Rating = Math.Round(sum / product.TotalReviews, 1);

            // Update the product and save the changes to the database
            unitOfWork.Products.Update(product);
            await unitOfWork.Save();



            // Setup the email
            emailService.SetupEmail(SetupEmail, new EmailSetupParams
            {
                CustomerId    = customerId,
                ProductId     = product.Id,
                Host          = GetHost(),
                ProductRating = review.Rating,
                Title         = review.Title,
                Text          = review.Text
            });



            return(Ok());
        }
예제 #20
0
 public ItemReview(ResourceData data) : base(data)
 {
     this.reviewData = (ReviewData)data;
 }