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)); } }
public override IReview CreateReview() { reviews.Move(); ReviewData rv = reviews.Current(); return(new PolandReview(new Review(rv.UserName, rv.Review))); }
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; } }
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); }
public ActionResult DeleteConfirmed(int id) { ReviewData reviewData = db.ReviewDatas.Find(id); db.ReviewDatas.Remove(reviewData); db.SaveChanges(); return(RedirectToAction("Index")); }
public ReviewDto Create() { var data = new ReviewData(); data.ReviewId = Guid.NewGuid(); MockDb.Reviews.Add(data); return(CreateDtoFromData(data)); }
private void AnimateOpening() { if (currentStatus == ReviewStatus.closed) { currentReview = nextReview; nextReview = null; StartCoroutine(AnimateOpeningCo(currentReview.reviewText)); } }
public static ReviewDto CreateDtoFromData(ReviewData data) { return(new ReviewDto() { Id = data.ReviewId, Rating = data.Rating, Comments = data.Comments, CustomerId = data.CustomerId }); }
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)); }
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)); }
// 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)); }
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); }
// 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)); }
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 })); } }
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) { } }
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); }
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); }
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()); }
public ItemReview(ResourceData data) : base(data) { this.reviewData = (ReviewData)data; }