public IActionResult CreateReview(ReviewEditModel model) { if (ModelState.IsValid) { int stars = 0; stars = Star(stars, model.One); stars = Star(stars, model.Two); stars = Star(stars, model.Three); stars = Star(stars, model.Four); stars = Star(stars, model.Five); var newReview = new Review(); newReview.Name = model.Name; newReview.Text = model.Text; newReview.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value; newReview.Stars = stars; newReview.restaurantId = model.Restaurant; newReview = _reviewData.Add(newReview); return(RedirectToPage("/Shared/ReviewPage")); } else { return(View()); } }
public async Task <IActionResult> EditReview(ReviewEditModel model, long reviewId) { var seller = await HttpContext.GetSellerAsync(); var customer = await HttpContext.GetMemberAsync(); var review = await _reviewService.GetAsync(new ReviewFilter { SellerId = seller.Id, CustomerId = customer.Id, ReviewId = reviewId }); if (review == null) { return(NotFound()); } if (HttpMethods.IsGet(Request.Method)) { ModelState.Clear(); await _appService.PrepareModelAsync(model, review); } else if (HttpMethods.IsPost(Request.Method)) { if (ModelState.IsValid) { var existingApproved = review.Approved; await _appService.PrepareReviewAsync(review, model); review.Approved = existingApproved; await _reviewService.UpdateAsync(review); TempData.AddAlert(AlertMode.Notify, AlertType.Success, $"\"{review.Title}\" review was updated."); } } return(PartialView("ReviewEdit", model)); }
public async Task <IActionResult> AddReview(ReviewEditModel model, long productId) { if (HttpMethods.IsGet(Request.Method)) { ModelState.Clear(); await _appService.PrepareModelAsync(model, null); } else if (HttpMethods.IsPost(Request.Method)) { if (ModelState.IsValid) { var seller = await HttpContext.GetSellerAsync(); var customer = await HttpContext.GetMemberAsync(); var review = new Review(); await _appService.PrepareReviewAsync(review, model); review.ProductId = productId; review.CustomerId = customer.Id; review.Approved = true; await _reviewService.CreateAsync(review); TempData.AddAlert(AlertMode.Notify, AlertType.Success, $"\"{review.Title}\" review was added."); } } return(PartialView("ReviewEdit", model)); }
public void Edit(ReviewEditModel model) { var entity = reviewRepository.Get(model.Id); entity.IsValid = model.IsValid; reviewRepository.Update(entity); }
public List <ManualQaFieldIndicator> GetManualQaFieldIndicators(ReviewEditModel m) { return(GetFieldIndicators().Select(f => new ManualQaFieldIndicator { FieldIdentifier = f.FieldIdentifier, IsChangeRequested = m.SelectedFieldIdentifiers.Contains(f.FieldIdentifier) }).OrderBy(f => f.FieldIdentifier).ToList()); }
public IHttpActionResult Edit(ReviewEditModel model) { return(Command <EditReviewCommand>( cmd => { cmd.Model = model; }, cmd => Ok(cmd.Model.Id))); }
public void Create(ReviewEditModel model) { var entity = Mapper.Map <Review>(model); entity.CreatedByUserId = model.CreatedByUserId; entity.CreatedDateTime = DateTime.Now; entity.IsValid = true; reviewRepository.Insert(entity); model.Id = entity.Id; }
public Task PrepareReviewAsync(Review review, ReviewEditModel model) { if (review == null) { throw new ArgumentNullException(nameof(review)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } review = _mapper.Map(model, review); return(Task.CompletedTask); }
public Task PrepareModelAsync(ReviewEditModel model, Review review) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (review != null) { model = _mapper.Map(review, model); } else { } return(Task.CompletedTask); }
public async Task <ReviewViewModel> GetReviewViewModelAsync(ReviewEditModel model, VacancyUser user) { var vm = await GetReviewViewModelAsync(model.ReviewId, user); foreach (var field in vm.FieldIdentifiers) { field.Checked = model.SelectedFieldIdentifiers.Contains(field.FieldIdentifier); } foreach (var automatedQaResult in vm.AutomatedQaResults) { automatedQaResult.Checked = model.SelectedAutomatedQaResults.Contains(automatedQaResult.OutcomeId); } vm.ReviewerComment = model.ReviewerComment; return(vm); }
public async Task <IActionResult> Submit(ReviewEditModel model) { if (ModelState.IsValid == false) { var vm = await _orchestrator.GetReviewViewModelAsync(model, User.GetVacancyUser()); return(View("Review", vm)); } var nextVacancyReviewId = await _orchestrator.SubmitReviewAsync(model, User.GetVacancyUser()); if (nextVacancyReviewId == null) { return(RedirectToRoute(RouteNames.Dashboard_Index_Get)); } return(RedirectToRoute(RouteNames.Vacancy_Review_Get, new { reviewId = nextVacancyReviewId })); }
public async Task <IActionResult> Edit(long id) { var seller = await HttpContext.GetMemberAsync(); var review = await _reviewService.GetAsync(new ReviewFilter() { SellerId = seller.Id, ReviewId = id }); if (review != null) { var model = new ReviewEditModel(); await _appService.PrepareModelAsync(model, review); return(View(nameof(Edit), model)); } return(RedirectToAction(nameof(Index))); }
public async Task <Guid?> SubmitReviewAsync(ReviewEditModel m, VacancyUser user) { var review = await _vacancyClient.GetVacancyReviewAsync(m.ReviewId); await EnsureUserIsAssignedAsync(review, user.UserId); var manualQaFieldIndicators = _mapper.GetManualQaFieldIndicators(m); var selectedAutomatedQaRuleOutcomeIds = m.SelectedAutomatedQaResults.Select(Guid.Parse).ToList(); if (m.IsRefer) { await _vacancyClient.ReferVacancyReviewAsync(m.ReviewId, m.ReviewerComment, manualQaFieldIndicators, selectedAutomatedQaRuleOutcomeIds); } else { await _vacancyClient.ApproveVacancyReviewAsync(m.ReviewId, m.ReviewerComment, manualQaFieldIndicators, selectedAutomatedQaRuleOutcomeIds); } var nextVacancyReviewId = await AssignNextVacancyReviewAsync(user); return(nextVacancyReviewId); }
public async Task <IActionResult> Edit(ReviewEditModel model) { if (ModelState.IsValid) { var seller = await HttpContext.GetMemberAsync(); var review = await _reviewService.GetAsync(new ReviewFilter() { SellerId = seller.Id, ReviewId = model.Id }); if (review != null) { await _appService.PrepareReviewAsync(review, model); await _reviewService.UpdateAsync(review); TempData.AddAlert(AlertMode.Notify, AlertType.Success, $"\"{review.Title}\" review was updated."); } } return(RedirectToAction()); }