public async Task <IActionResult> SubmitFeedbackToOwner(RateAndCommentInputModel inputModel) { if (!this.ModelState.IsValid) { this.TempData["wrongFeedback"] = "Коментарът трябва да съдържа поне 50 символа и не повече от 500."; return(this.RedirectToAction("DogsitterSubmitFeedback", new { id = inputModel.NotificationId })); } var rating = new Rating { Score = inputModel.Score, DogsitterId = inputModel.DogsitterId, OwnerId = inputModel.OwnerId, SentBy = "Dogsitter", }; var comment = new Comment { Content = inputModel.Content, DogsitterId = inputModel.DogsitterId, OwnerId = inputModel.OwnerId, SentBy = "Dogsitter", RatingScore = inputModel.Score, }; var notification = new Notification { Content = "Имате нов отзив.", OwnerId = inputModel.OwnerId, DogsitterId = inputModel.DogsitterId, SentBy = "Dogsitter", ReceivedOn = DateTime.Now, }; // The dogsitter submits his/her feedback to the Owner after end of Appointment await this.commentsService.SubmitFeedback(comment, rating); // A notification is send to the Owner containing a link to his/her Comments await this.notificationsService.SendNotification(notification); await this.hubContext.Clients.User(notification.Owner.User.UserName).SendAsync("RefreshDocument", "Имате известие."); await this.hubContext.Clients.User(notification.Owner.User.UserName).SendAsync("ReceiveToast", "Имате известие."); return(this.RedirectToAction("Index", "Home")); }
public async Task <IActionResult> SubmitFeedbackToDogsitter(RateAndCommentInputModel inputModel) { if (!this.ModelState.IsValid) { this.TempData["wrongFeedback"] = "Коментарът трябва да съдържа поне 50 символа и не повече от 500."; return(this.RedirectToAction("OwnerSubmitFeedback", new { id = inputModel.NotificationId })); } var rating = new Rating { Score = inputModel.Score, DogsitterId = inputModel.DogsitterId, OwnerId = inputModel.OwnerId, SentBy = "Owner", }; var comment = new Comment { Content = inputModel.Content, DogsitterId = inputModel.DogsitterId, OwnerId = inputModel.OwnerId, SentBy = "Owner", RatingScore = inputModel.Score, }; var notification = new Notification { Content = "Имате нов отзив.", OwnerId = inputModel.OwnerId, DogsitterId = inputModel.DogsitterId, SentBy = "Owner", ReceivedOn = DateTime.Now, }; await this.commentsService.SubmitFeedback(comment, rating); await this.notificationsService.SendNotification(notification); var dogsitter = this.dogsittersService.GetDogsitterByDogsitterId(rating.DogsitterId); await this.notificationsService.RemoveCommentNotification(inputModel.NotificationId); await this.hubContext.Clients.User(dogsitter.User.UserName).SendAsync("RefreshDocument", "Имате известие"); return(this.RedirectToAction("Index", "Home")); }