Exemple #1
0
        public IHttpActionResult DeleteUserRatingForPlace([FromBody] UserPlaceRating userRating)
        {
            if (this.ratingRepository.DeleteUserRatingForPlace(userRating.UserId, userRating.PlaceId))
            {
                return(Ok());
            }

            return(this.Content(HttpStatusCode.BadRequest, "Something was wrong. Try again"));
        }
Exemple #2
0
        /// <summary>
        /// set user rating in DataBase
        /// </summary>
        /// <param name="userRating">User Place Rating model (user id, place id, rating)</param>
        /// <returns>bool value(true if success request, false if fail)</returns>
        public bool SetUserRatingForPlace(UserPlaceRating userRating)
        {
            using (SqlConnection connection =
                       new SqlConnection(Constants.Constants.ConnectionStrings.DatabaseConnectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand("InsertOrUpdateUsersPlaceRating", connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                command.Parameters.Add(new SqlParameter("@UserID", userRating.UserId));
                command.Parameters.Add(new SqlParameter("@PlaceID", userRating.PlaceId));
                command.Parameters.Add(new SqlParameter("@Rating", Convert.ToDecimal(userRating.Rating)));

                return(command.ExecuteNonQuery() != this.noRowsAffected);
            }
        }