public static string GetReviews(string sellerID, string productID, ReviewType reviewType, int pageNum, int rowsPerPage) { HttpRequest request = new HttpRequest(); request.IgnoreProtocolErrors = true; request.AddHeader(HttpHeader.Accept, "application/json"); //dynamic digiseller = new ExpandoObject(); //digiseller.seller.id = long.Parse(sellerID); //digiseller.product.id = long.Parse(productID); //digiseller.reviews.type = reviewType; //digiseller.pages.num = pageNum; //digiseller.pages.rows = rowsPerPage; string content = $"<digiseller.request><seller><id>{sellerID}</id></seller><product><id>{productID}</id></product><reviews><type>{reviewType}</type></reviews><pages><num>{pageNum}</num><rows>{rowsPerPage}</rows></pages></digiseller.request>"; HttpResponse response = request.Post($"http://shop.digiseller.ru/xml/shop_reviews.asp", content, "text/xml"); string responceString = response.ToString(); if (responceString.Contains("500 Internal Server Error")) { return(""); } XmlDocument doc = new XmlDocument(); doc.LoadXml(responceString); string json = JsonConvert.SerializeXmlNode(doc); //string jsonResponce = JsonConvert.SerializeXmlNode(responceString); return(json); }
public ReviewsResponse MovieReviews(long movieId, ReviewType type = ReviewType.Top_Critic, int pageLimit = 20, int page = 1, string country = "us") { var urlParams = new { review_type = type.ToString().ToLower(), page_limit = pageLimit, page, country }; var request = CreateRequest("movies/{movieId}/reviews.json", new { movieId }, urlParams); return(Execute <ReviewsResponse>(request)); }
/// <summary> /// Prepare review type model /// </summary> /// <param name="model">Review type model</param> /// <param name="reviewType">Review type</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Review type model</returns> public virtual ReviewTypeModel PrepareReviewTypeModel(ReviewTypeModel model, ReviewType reviewType, bool excludeProperties = false) { Action <ReviewTypeLocalizedModel, int> localizedModelConfiguration = null; if (reviewType != null) { //fill in model values from the entity model = model ?? reviewType.ToModel <ReviewTypeModel>(); //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = _localizationService.GetLocalized(reviewType, entity => entity.Name, languageId, false, false); locale.Description = _localizationService.GetLocalized(reviewType, entity => entity.Description, languageId, false, false); }; } //prepare localized models if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } return(model); }
/// <summary> /// Prepare review type model /// </summary> /// <param name="model">Review type model</param> /// <param name="reviewType">Review type</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the review type model /// </returns> public virtual async Task <ReviewTypeModel> PrepareReviewTypeModelAsync(ReviewTypeModel model, ReviewType reviewType, bool excludeProperties = false) { Func <ReviewTypeLocalizedModel, int, Task> localizedModelConfiguration = null; if (reviewType != null) { //fill in model values from the entity model ??= reviewType.ToModel <ReviewTypeModel>(); //define localized model configuration action localizedModelConfiguration = async(locale, languageId) => { locale.Name = await _localizationService.GetLocalizedAsync(reviewType, entity => entity.Name, languageId, false, false); locale.Description = await _localizationService.GetLocalizedAsync(reviewType, entity => entity.Description, languageId, false, false); }; } //prepare localized models if (!excludeProperties) { model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration); } return(model); }
public async Task <ActionResult <long> > AddReview([FromRoute] ReviewType reviewType, [FromBody] AddReviewCommand query) { query.ReviewType = reviewType; var result = await _mediator.Send(query); return(Ok(result)); }
public ReviewTypeForCreateVM(ReviewType t) { id = t.Id; name = t.Name; desc = ""; isNew = false; }
public async Task <ActionResult <PagedResultDto <CompanyDto> > > GetReviews([FromRoute] ReviewType reviewType, [FromBody] GetReviewsQuery query) { query.ReviewType = reviewType; var result = await _mediator.Send(query); return(Ok(result)); }
public async Task <List <Review> > GetReviews(String Id, ReviewType ReviewType, String Country = "us", Int32 Limit = 10, Int32 Page = 1) { Login.CheckInformationSet(); dynamic reviewsjson = await AsyncHelpers.RottenTomatoesLoadJObjectAsync( UrlBuilder.ReviewsUrl(Id, ReviewType, Country, Limit, Page)); List <Review> reviews = new List <Review>(reviewsjson.total); foreach (var review in reviewsjson.reviews) { Review r = new Review() { Critic = review.critic, Date = review.date != null ? (DateTime?)DateTime.Parse(review.date) : null, Freshness = review.freshness != null ? (RottenRating)Enum.Parse(typeof(RottenRating), review.freshness, true) : RottenRating.None, Publication = review.publication, Quote = review.quote, SourceUrl = review.links != null ? review.links.review : "" }; reviews.Add(r); } return(reviews); }
private bool TimeForNewCard() { if (newCount == 0) { return(false); } ReviewType spread = (ReviewType)JsonHelper.GetNameNumber(collection.Conf, "newSpread"); if (spread == ReviewType.LAST) { return(false); } else if (spread == ReviewType.FIRST) { return(true); } else if (newCardModulus != 0) { return(reps != 0 && (reps % newCardModulus == 0)); } else { return(false); } }
public IList<ReviewInfo> GetReview(ReviewType rt, int ID) { SqlHelper objSqlHelper = new SqlHelper(); List<ReviewInfo> reviews = new List<ReviewInfo>(); SqlParameter[] objParams = new SqlParameter[2]; objParams[0] = new SqlParameter("@reviewType", SqlDbType.Int, 4); objParams[1] = new SqlParameter("@ID", SqlDbType.Int, 4); objParams[0].Value = (int)rt; objParams[1].Value = ID; SqlDataReader reader = objSqlHelper.ExecuteReader("je_Reviews_GetReview", objParams); while (reader.Read()) { ReviewInfo item = new ReviewInfo(); item.ReviewID = reader.GetInt32(reader.GetOrdinal("ReviewID")); item.BookID = reader.GetInt32(reader.GetOrdinal("bookID")); item.PostIP = reader.GetString(reader.GetOrdinal("postIP")); item.PostTime = reader.GetDateTime(reader.GetOrdinal("postTime")); item.RateID = reader.GetInt32(reader.GetOrdinal("rate")); item.UserName = reader.GetString(reader.GetOrdinal("userName")); item.StatusID = reader.GetInt32(reader.GetOrdinal("status")); item.Content = reader.GetString(reader.GetOrdinal("content")); reviews.Add(item); } reader.Close(); return reviews; }
public bool ExistReview(string sDescription) { var chocorroles = new ReviewType(); var swap = chocorroles.getAll(); var qbo = (from s in swap where s.sDescription.Equals(sDescription) select s).Count(); return(qbo >= 1); }
public reviewTypeCompositeType getReviewTypeById(int iIdReviewType) { reviewTypeCompositeType etct = new reviewTypeCompositeType(); ReviewType et = new ReviewType(); etct = et.GetReviewTypeById(iIdReviewType); return(etct); }
public List <reviewTypeCompositeType> getAllReviewType() { List <reviewTypeCompositeType> lst = new List <reviewTypeCompositeType>(); ReviewType et = new ReviewType(); lst = et.getAll(); return(lst); }
public static ReviewTypeModel ToReviewTypeModel(this ReviewType reviewType) { return(new() { Name = reviewType.Name, Code = reviewType.Code }); }
/// <summary> /// 对奖项的项目进行重排 /// </summary> /// <param name="prizes"></param> /// <returns></returns> private async Task ReRankProjects(List <Prizes.Prize> prizes, ReviewType reviewType) { foreach (var prize in prizes) { //加入待评选项目 var projects = await ProjectRepository.GetAll().Where(o => o.PrizeId == prize.Id && (o.ProjectStatus == ProjectStatus.UnderReview || o.ProjectStatus == ProjectStatus.Reviewing || o.ProjectStatus == ProjectStatus.FinalReviewing)).ToListAsync(); if (reviewType == ReviewType.Initial) { if (prize.PrizeType == Prizes.PrizeType.Major) { //专业类需要分专业排名 var projectGroups = projects.GroupBy(o => o.PrizeSubMajorId); foreach (var projectGroup in projectGroups) { var i = 1; foreach (var project in projectGroup.OrderByDescending(o => o.ScoreInitial)) { project.RankInitial = i++; } } } else { projects = projects.OrderByDescending(o => o.ScoreInitial).ToList(); foreach (var project in projects) { project.RankInitial = projects.IndexOf(project) + 1; } } } if (reviewType == ReviewType.Finish) { if (prize.PrizeType == Prizes.PrizeType.Major) { //专业类需要分专业排名 var projectGroups = projects.GroupBy(o => o.PrizeSubMajorId); foreach (var projectGroup in projectGroups) { var i = 1; foreach (var project in projectGroup.OrderByDescending(o => o.ScoreFinal)) { project.RankFinal = i++; } } } else { projects = projects.OrderByDescending(o => o.ScoreFinal).ToList(); foreach (var project in projects) { project.RankFinal = projects.IndexOf(project) + 1; } } } } }
public async Task <IActionResult> Create(ReviewType serviceType) { if (ModelState.IsValid) { _db.Add(serviceType); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(serviceType)); }
public IEnumerable <ReviewType> GetFilterType(string userName, ReviewType defaultType = ReviewType.Automatic) { if (_cache.TryGetValue(userName, out UserPreferenceModel _preference)) { return(_preference.FilterType); } return(new List <ReviewType> { defaultType }); }
private long?GetReviewReferenceId(Review review, ReviewType reviewType) { if (review is CompanyReview && reviewType == ReviewType.Company) { return(((CompanyReview)review).CompanyId); } else if (review is ShopReview && reviewType == ReviewType.Shop) { return(((ShopReview)review).ShopId); } return(null); }
public static Review ToReviewEntity(this ReviewModel reviewModel, ReviewType reviewType = null) { return(new() { Id = reviewModel.Id, Title = reviewModel.Title, Text = reviewModel.Text, Mark = reviewModel.Mark, PosterUrl = reviewModel.PosterUrl, Type = reviewType }); }
public async Task <ForumReviews> Create(ForumReviewCreateViewModel model, ReviewType reviewType, string reviewingUserId) { if (!await userManager.Users.AnyAsync(u => u.Id == reviewingUserId)) { throw new ArgumentException("Не е намерен потребителят с който сте логнати!"); } ForumReviews reviewToBeCreated; //review created by this user for this item which has to be deleted ForumReviews reviewAlreadyCreatedByThisUser; switch (reviewType) { case ReviewType.Post: if (!await PostsManager.Exists(model.ReviewedItemId)) { throw new ArgumentException("Постът, на който искате да направите ревю не съществува!"); } reviewAlreadyCreatedByThisUser = await unitOfWork.ForumReviewsRepository.GetAll() .OfType <PostReviews>() .Where(r => r.UserId == reviewingUserId && r.PostId == model.ReviewedItemId) .FirstOrDefaultAsync(); reviewToBeCreated = Mapper.Map <PostReviews>(model, opts => opts.Items.Add("UserId", reviewingUserId)); break; case ReviewType.Comment: if (!await CommentsManager.Exists(model.ReviewedItemId)) { throw new ArgumentException("Коментарът, на който искате да направите ревю не съществува!"); } reviewAlreadyCreatedByThisUser = await unitOfWork.ForumReviewsRepository.GetAll() .OfType <PostReviews>() .Where(r => r.UserId == reviewingUserId && r.PostId == model.ReviewedItemId) .FirstOrDefaultAsync(); reviewToBeCreated = Mapper.Map <CommentReviews>(model, opts => opts.Items.Add("UserId", reviewingUserId)); break; default: throw new ArgumentException("Не се поддържат Ревюта от избраният от вас тип!"); } if (reviewAlreadyCreatedByThisUser != null) { unitOfWork.ForumReviewsRepository.Delete(reviewAlreadyCreatedByThisUser); } unitOfWork.ForumReviewsRepository.Add(reviewToBeCreated); await unitOfWork.SaveAsync(); return(reviewToBeCreated); }
/// <summary> /// 反对短评 /// </summary> /// <param name="media_id"></param> /// <returns></returns> public ApiModel DislikeReview(int media_id, int review_id, ReviewType review_type = ReviewType.Short) { ApiModel api = new ApiModel() { method = RestSharp.Method.POST, baseUrl = $"https://bangumi.bilibili.com/review/api/dislike", body = $"{ApiHelper.MustParameter(ApiHelper.AndroidKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" }; api.body += ApiHelper.GetSign(api.body, ApiHelper.AndroidKey); return(api); }
/// <summary> /// Updates a review type /// </summary> /// <param name="reviewType">Review type</param> public virtual void UpdateReviewType(ReviewType reviewType) { if (reviewType == null) { throw new ArgumentNullException(nameof(reviewType)); } _reviewTypeRepository.Update(reviewType); //event notification _eventPublisher.EntityUpdated(reviewType); }
/// <summary> /// Inserts a review type /// </summary> /// <param name="reviewType">Review type</param> public virtual void InsertReviewType(ReviewType reviewType) { if (reviewType == null) { throw new ArgumentNullException(nameof(reviewType)); } _reviewTypeRepository.Insert(reviewType); _cacheManager.RemoveByPrefix(NopCatalogDefaults.ReviewTypeByPrefixCacheKey); //event notification _eventPublisher.EntityInserted(reviewType); }
/// <summary> /// Updates a review type /// </summary> /// <param name="reviewType">Review type</param> public virtual void UpdateReviewType(ReviewType reviewType) { if (reviewType == null) { throw new ArgumentNullException(nameof(reviewType)); } _reviewTypeRepository.Update(reviewType); _cacheManager.RemoveByPattern(NopCatalogDefaults.ReviewTypeByPatternKey); //event notification _eventPublisher.EntityUpdated(reviewType); }
/// <summary> /// Delete review type /// </summary> /// <param name="reviewType">Review type</param> public virtual void DeleteReiewType(ReviewType reviewType) { if (reviewType == null) { throw new ArgumentNullException(nameof(reviewType)); } _reviewTypeRepository.Delete(reviewType); _cacheManager.RemoveByPattern(REVIEW_TYPE_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(reviewType); }
protected virtual void UpdateReviewTypeLocales(ReviewType reviewType, ReviewTypeModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(reviewType, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(reviewType, x => x.Description, localized.Description, localized.LanguageId); } }
public async Task <IActionResult> Edit(int id, ReviewType serviceType) { if (id != serviceType.Id) { return(NotFound()); } if (ModelState.IsValid) { _db.Update(serviceType); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(serviceType)); }
/// <returns>A task that represents the asynchronous operation</returns> protected virtual async Task UpdateReviewTypeLocalesAsync(ReviewType reviewType, ReviewTypeModel model) { foreach (var localized in model.Locales) { await _localizedEntityService.SaveLocalizedValueAsync(reviewType, x => x.Name, localized.Name, localized.LanguageId); await _localizedEntityService.SaveLocalizedValueAsync(reviewType, x => x.Description, localized.Description, localized.LanguageId); } }
private static void UpdateRequireESignature(ReviewType reviewType, ReviewSettings updatedReviewSettings, ReviewPackageRawData reviewRawData) { var settingChanged = (!reviewRawData.IsESignatureEnabled.HasValue && updatedReviewSettings.RequireESignature) || (reviewRawData.IsESignatureEnabled.HasValue && reviewRawData.IsESignatureEnabled.Value != updatedReviewSettings.RequireESignature); if (!settingChanged) { return; } if (reviewType == ReviewType.Formal && reviewRawData.Status == ReviewPackageStatus.Active) { throw ReviewsExceptionHelper.ReviewActiveFormalException(); } reviewRawData.IsESignatureEnabled = updatedReviewSettings.RequireESignature; }
public IEnumerable <ScoredAlbumDto> GetMostAcclaimed(ReviewType reviewType, int count) { return(this.context.Albums .Where(a => a.ReleaseStage != ReleaseStage.Secret && a.ApprovalStatus == ApprovalStatus.Approved) .ToList() .Select(a => new ScoredAlbumDto { Id = a.Id, Name = a.Name, AverageScore = a.Reviews.Where(r => r.ReviewType == reviewType).Any() ? a.Reviews.Where(r => r.ReviewType == reviewType).Average(r => r.ReviewScore) : 0, ArtistName = a.Artist?.UserName }) .OrderByDescending(a => a.AverageScore) .Take(count) .ToList()); }
private DialogResult ShowReviewForm(ReviewType reviewType) { InitReviewForm(true); reviewButton = review.button; if (reviewType == ReviewType.Return) { reviewButton.Text = "&Return"; reviewButton.ImageIndex = 0; } if (reviewType == ReviewType.Exit) { reviewButton.Text = "&Exit test"; reviewButton.ImageIndex = 1; } review.ShowDialog(); return(review.DialogResult); }
private static string GetReviewsFolder(ReviewType type) { var filePath = string.Empty; switch (type) { case ReviewType.AUTOMOTIVE: filePath = REVIEWS_AUTOMOTIVE; break; case ReviewType.CAMERA: filePath = REVIEWS_CAMERA_AND_PHOTO; break; case ReviewType.CELL_PHONE: filePath = REVIEWS_MOBILE; break; case ReviewType.ELECTRONICS: filePath = REVIEWS_ELECTRONICS; break; case ReviewType.GAME_SOFTWARE: filePath = REVIEWS_GAMES; break; case ReviewType.OFFICE_PRODUCTS: filePath = REVIEWS_OFFICE_PRODUCTS; break; case ReviewType.SOFTWARE: filePath = REVIEWS_SOFTWARE; break; case ReviewType.DRAGON_VERGE: filePath = REVIEWS_DRAGON_VERGE; break; case ReviewType.DRAGON_AMAZON: filePath = REVIEWS_DRAGON_AMAZON; break; } return filePath; }
private static IEnumerable<string> GetPositiveReviews(ReviewType type) { return ExtractReviews(GetReviewsFolder(type) + "positive.review", Mood.POSITIVE); }
private static IEnumerable<string> GetNegativeReviews(ReviewType type) { return ExtractReviews(GetReviewsFolder(type) + "negative.review", Mood.NEGATIVE); }
public static String ReviewsUrl(String Id, ReviewType ReviewType = ReviewType.All, String Country = "us", Int32 Limit = 10, Int32 Page = 1) { return String.Format(Constants.ReviewsUrl, Login.ConsumerKey, Id, ReviewType.ToString().ToLower(), Country, Limit, Page); }
/// <summary> /// 获取图书评论信息 /// </summary> /// <param name="blogID"></param> /// <returns></returns> public static IList<ReviewInfo> GetReview(ReviewType rt, int ID) { return reviews.GetReview(rt, ID); }