Example #1
0
 public void CreateReviewTest()
 {
     var service = new ReviewService(
         new ReviewRepositorioMock()); 
     var model = new Review(){ Comment = "test"};
     service.CreateReview(model);                
 }
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     using (PlanetWroxEntities myEntities = new PlanetWroxEntities())
     {
         Review myReview;
         if (_id == -1) // Insert new item
         {
             myReview = new Review();
             myReview.CreateDateTime = DateTime.Now;
             myReview.UpdateDateTime = myReview.CreateDateTime;
             myEntities.Reviews.Add(myReview);
         }
         else // update existing item
         {
             myReview = (from r in myEntities.Reviews
                         where r.Id == _id
                         select r).Single();
             myReview.UpdateDateTime = DateTime.Now;
         }
         myReview.Title = TitleText.Text;
         myReview.Summary = SummaryText.Text;
         myReview.Body = BodyText.Text;
         myReview.GenreId = Convert.ToInt32(GenreList.SelectedValue);
         myReview.Authorized = Authorized.Checked;
         myEntities.SaveChanges();
         Response.Redirect("Reviews.aspx");
     }
 }
Example #3
0
        public void Add(string gameTitle, int categoryId, string content, int minPlayers, int maxPlayers, int minAge, int minTime, string siteUrl, string creatorId, int? imageId = null)
        {
            var newReview = new Review
            {
                GameTitle = gameTitle,
                CategoryId = categoryId,
                Content = content,
                MinPlayers = minPlayers,
                MaxPlayers = maxPlayers,
                MinAgeRequired = minAge,
                MinPlayingTimeInMinutes = minTime,
                UrlToOfficialSite = siteUrl,
                CreatorId = creatorId
            };

            if (imageId != null && imageId != 0)
            {
                newReview.ImageId = (int)imageId;
            }
            else
            {
                newReview.ImageId = 1;
            }

            this.reviews.Add(newReview);
            this.reviews.Save();
        }
        /// <summary>
        /// by BestBuySKU
        /// </summary>
        /// <param name="product">BestBuySKU</param>
        public static void Do(Product product)
        {
            if (string.IsNullOrEmpty(product.BBYSKU))
                return;

            Remix.Server server = new Remix.Server("", "");
            Remix.Reviews remixReviews = server.GetReview(product.BBYSKU, 1);
            if (remixReviews.Count > 0)
            {
                foreach (var remixReview in remixReviews)
                {
                    Review review = new Review()
                                        {
                                            Title = remixReview.Title,
                                            Content = remixReview.Comment,
                                            Author = remixReview.Reviewer.Name,
                                            Source = "Best Buy",
                                            SourceUrl = ""
                                        };
                    DateTime.TryParse(remixReview.SubmissionTime, out review.PubTime);
                    decimal.TryParse(remixReview.Rating, out review.Rating);

                    product.Reviews.Add(review);
                }
            }
        }
Example #5
0
    protected void btnPost_Click(object sender, EventArgs e)
    {
        using (eCommerceDBEntities context = new eCommerceDBEntities())
        {
            if (Session["CustomerID"] != null)
            {
                int CustID = Convert.ToInt16(Session["CustomerID"].ToString());
                int ProdID = Convert.ToInt16(Request.QueryString["ProductID"]);

                Review rv = new Review()
                {
                    ReviewTitle = txtReviewTitle.Text,
                    ReviewDescription = txtReviewDetail.Text,
                    CustomerID = CustID,
                    ProductID = ProdID,
                    Rating = Convert.ToInt16(ddlRatings.SelectedValue),
                    ReviewDate = DateTime.Now
                };

                context.Reviews.AddObject(rv);
                context.SaveChanges();

                string notifyTitle = "Review added";
                string message = "Your review has been posted on the product page. Thanks for helping others.";
                string notification = string.Format("?notifyTitle={0}&notificationDescription={1}", notifyTitle, message);

                Response.Redirect("~/product.aspx?ProductID=" + ViewState["prodid"].ToString() + "&" + notification);
            }
        }
    }
        public void Init()
        {
            _trans = new TransactionScope();
            // make connection
            db = new ApplicationDbContext();

            //make controller
            controller = new ReviewController { DbContext = db };

            // seed the database if empty
            if (db.Members.Count() == 0)
            {
                new Migrations.Configuration().SeedDebug(db);
                Console.WriteLine("Seeded DB");
            }
            else
            {
                Console.WriteLine("DB Already seeded");
            }

            Review validTestReview = new Review();
            Game game = db.Games.FirstOrDefault();
            Member member = db.Members.FirstOrDefault();
            validTestReview.Game_Id = game.Id;
            validTestReview.Game = game;
            validTestReview.Author = member;
            validTestReview.Rating = 3;
            validTestReview.Body = "Great Game!";
            validTestReview.Subject = "Review Title";
            validTestReview.IsApproved = false;
            validTestReview.Aprover_Id = null;

            db.Reviews.Add(validTestReview);
            db.SaveChanges();
        }
Example #7
0
        public ReviewsInput( Review R )
            :this()
        {
            IsReview = true;

            StringResources stx = new StringResources( "AppBar" );
            Title.Text = stx.Text( "Reply" );
            TitleSection.Visibility = Visibility.Collapsed;
        }
        /// <summary>
        /// Updates a previously persisted Review instance.
        /// </summary>
        /// <param name="review">The review to Update.</param>
        public static void UpdateReview(Review review)
        {
            if (review.Id == -1)
                throw (new System.ArgumentException("Review is new instance and needs to be saved before updating."));

            ValidateReview(review);

            Data.ReviewSQL.UpdateReview(review);
        }
 public static void AddNewReview(Review dbNewReview)
 {
     using (ReviewsDataContext context = new ReviewsDataContext())
     {
         dbNewReview.DatePosted = DateTime.Now;
         context.Reviews.InsertOnSubmit(dbNewReview); //.InsertAllOnSubmit(dbUserModel);
         context.SubmitChanges();
     }
 }
        /// <summary>
        /// Persists a new Review instance.
        /// </summary>
        /// <param name="review">The Review to persist.</param>
        public static void CreateReview(Review review)
        {
            if (review.Id != -1)
                throw (new System.ArgumentException("Review is not a new instance."));

            ValidateReview(review);

            Data.ReviewSQL.CreateReview(review);
        }
        /// <summary>
        /// Adiciona uma review ao responseForm
        /// </summary>
        /// <param name="review"></param>
        /// <param name="responseFormId"></param>
        public void addReview(Review review)
        {
            if (review != null && review.ResponseFormId > 0)
            {
                review.Date = DateTime.Now;

                context.Reviews.Add(review);
                context.SaveChanges();
            }
        }
Example #12
0
		public ActionResult New(Review review)
		{
            if (ModelState.IsValid)
			{
				reviewRepository.SaveOrUpdate(review);
				return this.RedirectToAction(x => x.Submitted(review.Product.Id));
			}

			return View(review);
		}
        /// <summary>
        /// Validates the Review instance for persistance.
        /// </summary>
        /// <param name="review">The Review to validate.</param>
        private static void ValidateReview(Review review)
        {
            if (string.IsNullOrWhiteSpace(review.Body))
                throw (new System.ArgumentException("Review body cannot be null or whitespace."));

            if (review.RestaurantId == -1)
                throw (new System.ArgumentException("Review restaurant id is invalid."));

            if (review.MemberId == -1)
                throw (new System.ArgumentException("Review member id is invalid."));
        }
        /// <summary>
        /// Persists a new instance of a Review.
        /// </summary>
        /// <param name="restaurantId">The ID of the Restaurant to create a Review for.</param>
        /// <param name="memberId">The ID of the Member who created the Review.</param>
        /// <param name="body">The textual content of the Review.</param>
        /// <returns>An instance of the persisted Review.</returns>
        public static Review CreateReview(long restaurantId, long memberId, string body)
        {
            Review review = new Review();
            review.RestaurantId = restaurantId;
            review.MemberId = memberId;
            review.Body = body;

            CreateReview(review);

            return review;
        }
		public void NewWithPost_saves_review()
		{
            var review = new Review { Product = new Product { Id = 5 } };
			
			controller.New(review)
				.ReturnsRedirectToRouteResult()
				.ToAction("Submitted")
                .WithRouteValue("Id", "5");

			reviewRepository.AssertWasCalled(x => x.SaveOrUpdate(review));
		}
Example #16
0
        public ActionResult Create(Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(review);
        }
Example #17
0
 //TODO basic error handling
 public IHttpActionResult Post(Review review)
 {
     try
     {
         reviewService.SaveReview(review);
         return Ok(review);
     }
     catch (DbUpdateException)
     {
         return BadRequest("Unable to upload user review.");
     }
 }
Example #18
0
 public int CreateReview(Review R)
 {
     try
     {
         this.db.Reviews.Add(R);
         return db.SaveChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Example #19
0
 public EmployeeReviews(Employee pCurrEmployee,Review pCurrReview,int pID,String pEmployeeName, String pLineManager, DateTime pDeadline, String pType, String pFeedback,String pStatus)
 {
     ReviewID = pID;
        EmployeeName = pEmployeeName;
        LineManager = pLineManager;
        Deadline = pDeadline;
        Type = pType;
        Status = pStatus ;
        Feedback = pFeedback;
        CurrEmployee = pCurrEmployee;
        CurrReview = pCurrReview;
 }
Example #20
0
        public async Task OpenReview( Review R )
        {
            CommentLoader CL = new CommentLoader(
                R.Id
                , X.Call<XKey[]>( XProto.WRequest, "GetReplies", R.Id )
                , new CommentLoader.CommentXMLParser( GetReplies )
            );

            IList<Comment> FirstLoad = await CL.NextPage();

            Replies.ConnectLoader( CL );
            Replies.UpdateSource( FirstLoad );
        }
Example #21
0
        public static string Add(int partID = 0, int rating = 0, string subject = "", string review_text = "", string name = "", string email = "", int reviewID = 0)
        {
            if (partID == 0 || review_text.Length == 0) {
                return "{\"error\":\"Invalid data.\"}";
            }

            try {
                CurtDevDataContext db = new CurtDevDataContext();
                Review r = new Review();
                if (reviewID == 0) {
                    // Create new review
                    r = new Review {
                        partID = partID,
                        rating = rating,
                        subject = subject,
                        review_text = review_text,
                        name = name,
                        email = email,
                        createdDate = DateTime.Now,
                        approved = false,
                        active = true,
                        cust_id = 1
                    };
                    db.Reviews.InsertOnSubmit(r);
                    db.SubmitChanges();

                } else {
                    r = (from rev in db.Reviews
                         where rev.reviewID.Equals(reviewID)
                         select rev).FirstOrDefault<Review>();
                    r.name = name;
                    r.review_text = review_text;
                    r.rating = rating;
                    r.subject = subject;
                    r.email = email;
                    db.SubmitChanges();

                }

                r = Get(r.reviewID);
                try {
                    ProductModels.UpdatePart((int)r.partID);
                } catch { }

                JavaScriptSerializer js = new JavaScriptSerializer();
                return js.Serialize(r);

            } catch (Exception e) {
                return "{\"error\":\"" + e.Message + "\"}";
            }
        }
        public void ShouldBeAbleToSaveAndRetrieveReviews()
        {
            InSession(session =>
            {
                var product = new Product
                {
                    Name = "My Cool Product"
                };
                session.Save(product);

                var review = new Review
                {
                    Approved = true,
                    Text = "Great product",
                    Reviewer = "Mike",
                    Product = product
                };

                session.Save(review);

                var comment = new Comment
                {
                    Approved = true,
                    Text = "Great site",
                    Reviewer = "John"
                };
                session.Save(comment);
            });

            Console.WriteLine("IComment");
            InSession(session =>
            {
                var comments = session.Query<IComment>().OrderByDescending(c => c.Id);
                foreach (var comment in comments)
                {
                    Console.WriteLine("{0}: {1}", comment.Id, comment.Reviewer);
                }
            });

            Console.WriteLine("Reviews");
            InSession(session =>
            {
                var reviews = session.Query<Review>();
                foreach (var review in reviews)
                {
                    Console.WriteLine("{0}: {1}", review.Id, review.Reviewer);
                }
            });
        }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        MP1.Hide();
        String reviewText = tbxReview.Text;
        tbxReview.Text = "";

        User u = ConnectionClass.GetUserById((int)Session["user_id"]);

            int rating = (int)Session["review_rating"];
            Session["review_rating"] = 0;
            Review review = new Review(u, product, reviewText, rating);

            ConnectionClass.AddReview(review);
            Response.Redirect(Request.RawUrl);
    }
        private static ReviewDTO MapReview(Review review)
        {
            var reviewToReturn = new ReviewDTO
                                     {
                                         ASIN = review.ASIN,
                                         Rating = review.Rating,
                                         Summary = review.Summary,
                                         Content = review.Content,
                                         Date = Convert.ToDateTime(review.Date),
                                         HelpfulVotes = Convert.ToInt32(review.HelpfulVotes),
                                         TotalVotes = Convert.ToInt32(review.TotalVotes),
                                     };

            return reviewToReturn;
        }
Example #25
0
        private static List<Review> EnumerateReviewSqlDataReader(SqlDataReader reader)
        {
            List<Review> reviews = new List<Review>();

            while (reader.Read())
            {
                Review review = new Review();
                review.Id = (long)reader["id"];
                review.RestaurantId = (long)reader["restaurant_id"];
                review.MemberId = (long)reader["member_id"];
                review.Body = (string)reader["body"];
                reviews.Add(review);
            }

            return reviews;
        }
Example #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Review rev = new Review();
            rev.GenerateReview1();
            lblReview1.Text = "<I>" + rev.quote + "</I>";
            lblSource1.Text = "&nbsp;&nbsp;-" + rev.source;
            rev.ClearReview();

            Review rev2 = new Review();
            rev2.GenerateReview2();
            lblReview2.Text = "<I>" + rev2.quote + "</I>";
            lblSource2.Text = "&nbsp;&nbsp;-" + rev2.source;
            rev2.ClearReview();
        }
    }
Example #27
0
    protected void btnRefresh_Click(object sender, EventArgs e)
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
        GC.Collect();

        Review rev = new Review();
        rev.GenerateReview1();
        lblReview1.Text = "<I>" + rev.quote + "</I>";
        lblSource1.Text = "&nbsp;&nbsp;-" + rev.source;
        rev.ClearReview();

        Review rev2 = new Review();
        rev2.GenerateReview2();
        lblReview2.Text = "<I>" + rev2.quote + "</I>";
        lblSource2.Text = "&nbsp;&nbsp;-" + rev2.source;
        rev2.ClearReview();
    }
Example #28
0
        public static Review CreateReview(BookstoreEntities entities, string text, string dateStr, string authorName)
        {
            var review = new Review() { Date = DateTime.Now, Content = text };
            if (authorName != null)
            {
                var author = entities.Authors.FirstOrDefault(a => a.Name == authorName);
                review.Author = author;
            }

            if (dateStr != null)
            {
                var date = DateTime.Parse(dateStr);
                review.Date = date;
            }

            entities.Reviews.Add(review);

            return review;
        }
Example #29
0
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtTitle.Text) && !string.IsNullOrEmpty(txtReview.Text)) {
     //Check again just in case the user submitted a review from a second window.
     if (ReviewController.UserReviewedProduct(_product.ProductId, WebUtility.GetUserName())) {
       lblAlreadyReviewed.Visible = true;
     }
     else {
       Review review = new Review();
       review.ProductId = _product.ProductId;
       review.Rating = reviewRating.CurrentRating;
       review.Title = txtTitle.Text.Trim();
       review.Body = txtReview.Text;
       review.Save(WebUtility.GetUserName());
       lblReviewSaved.Visible = true;
     }
     pnlReview.Visible = false;
       }
 }
Example #30
0
        /// <summary>
        /// Updates a previously created Review instance.
        /// </summary>
        /// <param name="review">The Review instance to update.</param>
        public static void UpdateReview(Review review)
        {
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RestaurantReviews"].ConnectionString))
            {
                con.Open();
                using (SqlCommand com = new SqlCommand("UpdateReview", con))
                {
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.Add(new SqlParameter { ParameterName = "@reviewId", SqlDbType = SqlDbType.BigInt, Value = review.Id });
                    com.Parameters.Add(new SqlParameter { ParameterName = "@restaurantId", SqlDbType = SqlDbType.BigInt, Value = review.RestaurantId });
                    com.Parameters.Add(new SqlParameter { ParameterName = "@memberId", SqlDbType = SqlDbType.BigInt, Value = review.MemberId });
                    com.Parameters.Add(new SqlParameter { ParameterName = "@body", SqlDbType = SqlDbType.NVarChar, Value = review.Body });

                    if (com.ExecuteNonQuery() != 1)
                        throw (new PersistanceException($"Failed to update review, ID={review.Id}."));
                }
                con.Close();
            }
        }
        public void UpdateCell(Review review)
        {
            try
            {
                string url = review.SmallImageURL;
                if (url == null)
                {
                    url = review.Barcode + ".jpg";
                }
                imageView.SetImage(BlobWrapper.GetResizedImage(url, new CGRect(0, 0, 100, 155), review.PlantFinal), UIControlState.Normal);
                separator.Image = UIImage.FromFile("separator.png");
                if (review.Vintage.Length < 4)
                {
                    btnItemname.SetTitle(review.Name + " ", UIControlState.Normal);
                }
                else
                {
                    btnItemname.SetTitle(review.Name + " " + review.Vintage, UIControlState.Normal);
                }
                ReviewDate.Text = review.Date.ToString("MM-dd-yyyy");
                Comments.Text   = review.RatingText;
                if (review.RatingText.Length > 97)
                {
                    ReadMore.Frame          = new CGRect(ContentView.Bounds.Width - 25, 160, 70, 25);
                    ReadMore.TouchUpInside += delegate {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = review.RatingText,
                            //Message = "Coming Soon..."
                        };

                        alert.AddButton("OK");
                        alert.Show();
                    };
                }
                if (review.Liked == 1)
                {
                    btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                    //btnLike.TouchUpInside +=async delegate {
                    //	btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                    //		SKULike like = new SKULike();
                    //		like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId());
                    //		like.BarCode = WineIdLabel.Text;
                    //		like.Liked = Convert.ToBoolean(0);
                    //		myItem.IsLike = Convert.ToBoolean(0);
                    //		await sw.InsertUpdateLike(like);
                    //};
                    btnLike.Tag = 1;
                }
                else
                {
                    btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                    btnLike.Tag = 0;
                }
                //if (review.  == true)
                //	{
                //		heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                //	}
                //CGSize sTemp = new CGSize(ContentView.Frame.Width, 100);
                //sTemp = Comments.SizeThatFits(sTemp);
                //if (review.RatingText.Length > 100)
                //{
                //	//ContentView.AddSubview(ReadMore);
                //	ReadMore.TouchUpInside += delegate {
                //		{
                //			UIAlertView alert = new UIAlertView()
                //			{
                //				Title = review.RatingText,
                //				//Message = "Coming Soon..."
                //			};

                //			alert.AddButton("OK");
                //			alert.Show();
                //		};
                //	};
                //	//ReadMore.Hidden = false;
                //}
                //Vintage.Text = " ";//"Vintage:"+review.Vintage.ToString();
                storeid          = Convert.ToInt32(review.PlantFinal);
                WineIdLabel.Text = review.Barcode.ToString();
                ReadMore.SetTitle("... Read More", UIControlState.Normal);
                ReadMore.SetTitleColor(UIColor.Black, UIControlState.Normal);
                ReadMore.BackgroundColor = UIColor.White;
                stars.AverageRating      = Convert.ToDecimal(review.RatingStars);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
Example #32
0
 public IActionResult AddReview(Review review)
 {
     repository.AddReview(review);
     return(RedirectToAction(nameof(Index)));
 }
Example #33
0
 public async Task AddAnswerToReviewAsync(Review review)
 {
     _context.Reviews.Update(review);
     await _context.SaveChangesAsync();
 }
Example #34
0
 public async Task AddReviewAsync(Review review)
 {
     await _context.Reviews.AddAsync(review);
     await _context.SaveChangesAsync();
 }
 public void SendReview(Review review)
 {
     reviewRepository.SendReview(review);
 }
        public MyReviewCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            try
            {
                btnBack = new UIButton();
                btnBack.BackgroundColor        = UIColor.FromRGB(63, 63, 63);
                btnBack.UserInteractionEnabled = false;
                SelectionStyle             = UITableViewCellSelectionStyle.Gray;
                imageView                  = new UIButton();
                imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                imageView.ContentMode      = UIViewContentMode.Center;
                imageView.ClipsToBounds    = true;
                //imageView.TouchDown += (object sender, EventArgs e) =>
                //{
                //	BTProgressHUD.Show("Loading...");
                //};
                imageView.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show(LoggingClass.txtloading);
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                Review review = new Review();
                separator = new UIImageView();

                btnItemname = new UIButton();
                btnItemname.SetTitle("", UIControlState.Normal);
                btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal);
                btnItemname.Font                = UIFont.FromName("Verdana-Bold", 13f);
                btnItemname.LineBreakMode       = UILineBreakMode.WordWrap;
                btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                btnItemname.TouchUpInside      += delegate
                {
                    BTProgressHUD.Show("Loading...");
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                ReviewDate = new UILabel()
                {
                    Font      = UIFont.FromName("AmericanTypewriter", 10f),
                    TextColor = UIColor.FromRGB(38, 127, 200),
                    //TextAlignment = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                Comments = new UITextView()
                {
                    Font          = UIFont.FromName("AmericanTypewriter", 14f),
                    TextColor     = UIColor.FromRGB(55, 127, 0),
                    TextAlignment = UITextAlignment.Justified,
                    //TextAlignment = UITextAlignment.Natural,
                    BackgroundColor = UIColor.Clear,
                    //LineBreakMode = UILineBreakMode.WordWrap
                    Editable   = false,
                    Selectable = false
                };
                ReadMore = new UIButton()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    BackgroundColor = UIColor.White
                };
                Vintage = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    TextColor       = UIColor.FromRGB(127, 51, 100),
                    BackgroundColor = UIColor.Clear
                };
                decimal averageRating = 0.0m;
                var     ratingConfig  = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"),
                                                         filledImage: UIImage.FromBundle("Stars/star.png"),
                                                         chosenImage: UIImage.FromBundle("Stars/star.png"));
                stars   = new PDRatingView(new CGRect(110, 60, 60, 20), ratingConfig, averageRating);
                btnEdit = new UIButton();
                btnEdit.SetImage(UIImage.FromFile("edit.png"), UIControlState.Normal);
                btnEdit.TouchUpInside += (sender, e) =>
                {
                    PopupView yourController = new PopupView(WineIdLabel.Text, storeid);
                    yourController.NavController  = NavController;
                    yourController.parent         = Parent;
                    yourController.StartsSelected = stars.AverageRating;
                    yourController.Comments       = Comments.Text;
                    LoggingClass.LogInfo("Edited the review of " + wineId, screenid);


                    //yourController.WineId = Convert.ToInt32(WineIdLabel.Text);
                    yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                    //this.PresentViewController(yourController, true, null);
                    Parent.PresentModalViewController(yourController, false);
                };
                btnDelete = new UIButton();
                btnDelete.SetImage(UIImage.FromFile("delete.png"), UIControlState.Normal);
                btnDelete.TouchUpInside += (sender, e) =>
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Delete Review ",
                        Message = LoggingClass.txtdeletereview,
                    };
                    alert.AddButton("Yes");
                    alert.AddButton("No");

                    alert.Clicked += async(senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 0)
                        {
                            review.Barcode      = WineIdLabel.Text;
                            review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId());
                            BTProgressHUD.Show("Deleting review");
                            await sw.DeleteReview(review);

                            LoggingClass.LogInfo("Deleting the review of " + wineId, screenid);
                            BTProgressHUD.ShowSuccessWithStatus("Done");
                            ((IPopupParent)Parent).RefreshParent();
                        }
                    };

                    alert.Show();
                };
                btnLike = new UIButton();
                btnLike.ClipsToBounds              = true;
                btnLike.Layer.BorderColor          = UIColor.White.CGColor;
                btnLike.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                btnLike.Tag = 0;
                //myItem = new Item();
                //bool count =Convert.ToBoolean( myItem.IsLike);
                //if (count == true)
                //{
                //btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);}
                //else
                //{
                //	btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                //}
                btnLike.TouchUpInside += async(object sender, EventArgs e) =>
                {
                    try
                    {
                        UIButton temp = (UIButton)sender;
                        if (temp.Tag == 0)
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                            temp.Tag   = 1;
                            Data.Liked = 1;
                            //btnLike.Tag = 1;
                            LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screenid);
                        }
                        else
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                            temp.Tag   = 0;
                            Data.Liked = 0;

                            LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screenid);
                        }
                        SKULike like = new SKULike();
                        like.UserID  = Convert.ToInt32(CurrentUser.RetreiveUserId());
                        like.BarCode = WineIdLabel.Text;
                        like.Liked   = Convert.ToBoolean(temp.Tag);

                        Data.Liked = Convert.ToInt32(temp.Tag);
                        await sw.InsertUpdateLike(like);
                    }
                    catch (Exception ex)
                    {
                        LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
                    }
                };
                WineIdLabel = new UILabel();
                ContentView.AddSubviews(new UIView[] { btnBack, btnItemname, ReadMore, ReviewDate, Comments, stars, imageView, Vintage, separator, btnEdit, btnDelete, btnLike });
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
Example #37
0
 public bool DeleteReview(Review review)
 {
     _reviewContext.Remove(review);
     return(Save());
 }
Example #38
0
 public ActionResult Edit(Review review)
 {
     return(View());
 }
Example #39
0
 public void SubmitReview(string SBSID, Review review)
 {
     throw new NotImplementedException();
 }
 public void SaveReview(Review review)
 {
     _context.SaveReview(review);
 }
Example #41
0
        private static void Import()
        {
            var xmlBooks = XElement.Load(xmlFilesLocation + xmlImportFileName).Elements();

            foreach (var xmlBook in xmlBooks)
            {
                var currentBook = new Book();
                currentBook.Titles = xmlBook.Element("title").Value;

                var isbn = xmlBook.Element("isbn");
                if (isbn != null)
                {
                    var bookExist = db.Books.Any(b => b.ISBN == isbn.Value);
                    if (bookExist)
                    {
                        throw new ArgumentException("ISBN already exists");
                    }

                    currentBook.ISBN = isbn.Value;
                }

                var price = xmlBook.Element("price");
                if (price != null)
                {
                    currentBook.Price = decimal.Parse(price.Value);
                }

                var webSite = xmlBook.Element("web-site");
                if (webSite != null)
                {
                    currentBook.WebSite = webSite.Value;
                }

                var xmlAuthors = xmlBook.Element("authors");
                if (xmlAuthors != null)
                {
                    foreach (var xmlAuthor in xmlAuthors.Elements("author"))
                    {
                        var authorName = xmlAuthor.Value;
                        var author     = GetAuthor(authorName);
                        currentBook.Authors.Add(author);
                    }
                }

                var xmlReviews = xmlBook.Element("reviews");
                if (xmlReviews != null)
                {
                    foreach (var xmlReview in xmlReviews.Elements("review"))
                    {
                        var reviewDate = xmlReview.Attribute("date");

                        var review = new Review
                        {
                            Content    = xmlReview.Value,
                            CreateedOn = reviewDate == null ? DateTime.Today : DateTime.Parse(reviewDate.Value),
                        };

                        var authorName = xmlReview.Attribute("author");
                        if (authorName != null)
                        {
                            review.Author = GetAuthor(authorName.Value);
                        }

                        currentBook.Reviews.Add(review);
                    }
                }

                db.Books.Add(currentBook);
                db.SaveChanges();
            }
        }
Example #42
0
 public void DeleteReview(Review r)
 {
     db.Review.Remove(r);
 }
Example #43
0
 public Review Update(Review review)
 {
     _model.Entry(review).State = EntityState.Modified;
     _model.SaveChanges();
     return(review);
 }
Example #44
0
 public bool UpdatedReview(Review review)
 {
     _reviewContext.Update(review);
     return(Save());
 }
 public PdfBuilder(Review review, string file, string css)
 {
     _review = review;
     _file   = file;
     _css    = css;
 }
Example #46
0
 public bool CreateReview(Review review)
 {
     _reviewContext.Add(review);
     return(Save());
 }
 public IActionResult Review(Review review, int RecipeId)
 {
     review.RecipeId = RecipeId;
     repository.SaveReview(review);
     return(Redirect("List?recipeid= " + RecipeId));
 }
        private void SetContent(XElement reviewXElement, Review review)
        {
            var reviewContent = reviewXElement.Value.Trim();

            review.Content = reviewContent;
        }
Example #49
0
 public void AddReview(Product p, Review r)
 {
     p.Reviews.Add(r);
 }
Example #50
0
 public Review Insert(Review newReview)
 {
     _db.Add(newReview);
     _model.SaveChanges();
     return(newReview);
 }
Example #51
0
        public ActionResult AddReview(Review rev, string ReviewContent)
        {
            var barrev = BarLogic.AddReviewLogic(rev);

            return(View("BarDetails", barrev));
        }
Example #52
0
        public void TestGetReviewByAccommodationOk()
        {
            Review review1 = new Review()
            {
                Id        = 1,
                Comment   = "Prueba1",
                Score     = 3,
                BookingId = 1
            };
            Review review2 = new Review()
            {
                Id        = 3,
                Comment   = "Prueba12",
                Score     = 4,
                BookingId = 2
            };
            List <Review> reviews = new List <Review>()
            {
                review1,
                review2
            };

            _context.Add(
                new Accommodation()
            {
                Id   = 1,
                Name = "a"
            }
                );
            _context.Add(
                new Accommodation()
            {
                Id   = 2,
                Name = "b"
            }
                );
            _context.Add(new Booking
            {
                Id = 1,
                AccommodationId = 1,
                BookingHistory  = new List <BookingStage>(),
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(3),
                GuestId         = 2,
                Guests          = new List <Guest>(),
                HeadGuest       = new Tourist()
                {
                    Email = "*****@*****.**"
                },
                TotalPrice = 35
            });
            _context.Add(new Booking
            {
                Id = 2,
                AccommodationId = 1,
                BookingHistory  = new List <BookingStage>(),
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(3),
                GuestId         = 2,
                Guests          = new List <Guest>(),
                HeadGuest       = new Tourist()
                {
                    Email = "*****@*****.**"
                },
                TotalPrice = 35
            });
            _context.Add(new Booking
            {
                Id = 3,
                AccommodationId = 2,
                BookingHistory  = new List <BookingStage>(),
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(3),
                GuestId         = 2,
                Guests          = new List <Guest>(),
                HeadGuest       = new Tourist()
                {
                    Email = "*****@*****.**"
                },
                TotalPrice = 35
            });
            _context.Add(new Review()
            {
                Id        = 2,
                Comment   = "Prueba123",
                Score     = 1,
                BookingId = 3
            });
            reviews.ForEach(r => _context.Add(r));
            _context.SaveChanges();
            var repository = new ReviewRepository(_context);

            var result = repository.GetByAccommodation(1);

            Assert.IsTrue(reviews.SequenceEqual(result));
        }
Example #53
0
 public void AddReview(Review r)
 {
     db.Review.Add(r);
 }
Example #54
0
        public async Task <Review> NewReview(Review review)
        {
            if (review != null)
            {
                IDictionary <int, string> lookup = await _productReviewRepository.LoadLookupAsync();

                // Console.WriteLine($"    >>>>>>>>>>>>>>>>>   ID:{review.Id}  Exists?{lookup.ContainsKey(review.Id)}");

                int maxKeyValue = 0;
                if (lookup != null && lookup.Count > 0)
                {
                    maxKeyValue = lookup.Keys.Max();
                }
                else
                {
                    lookup = new Dictionary <int, string>();
                }

                review.Id      = ++maxKeyValue;
                review.CacheId = review.Id;
                //if(string.IsNullOrWhiteSpace(review.ReviewerName))
                //{
                //    review.ReviewerName = string.Empty;
                //    //review.ReviewerName = "anon";
                //}

                if (string.IsNullOrWhiteSpace(review.ReviewDateTime))
                {
                    review.ReviewDateTime = DateTime.Now.ToString();
                }

                //if (string.IsNullOrWhiteSpace(review.Sku))
                //{
                //    review.Sku = string.Empty;
                //}

                string productId = review.ProductId;

                IList <Review> reviews = await this._productReviewRepository.GetProductReviewsAsync(productId);

                if (reviews == null)
                {
                    reviews = new List <Review>();
                }

                reviews.Add(review);

                Console.WriteLine($"    >>>>>>>>>>>>>>>>>   Saving [{review.Id}] {productId}");

                await this._productReviewRepository.SaveProductReviewsAsync(productId, reviews);

                lookup.Add(review.Id, review.ProductId);
                await this._productReviewRepository.SaveLookupAsync(lookup);
            }
            else
            {
                Console.WriteLine("-!-!- New Review - Null review.");
            }

            return(review);
        }
 public void AddReview(Review review)
 {
     reviews.Add(review);
 }
Example #56
0
 public void DropReview(Review review)
 {
     this.DropReview(review.Id);
 }
        public Review GetReviewById(int id)
        {
            Review review = reviews.Find(r => r.ReviewID == id);

            return(review);
        }
Example #58
0
 static void Main(string[] args)
 {
     Console.WriteLine("Hello World!");
     Review review = new Review();
 }
Example #59
0
 public void CreateReview(Review review)
 {
     _context.Reviews.Add(review);
     _context.SaveChanges();
 }
Example #60
0
 public void Add(Review review)
 {
     dbContext.Reviews.AddObject(review);
     dbContext.SaveChanges();
 }