コード例 #1
0
        public ActionResult NewReview(NewEventReviewViewModel model)
        {
            if (!ModelState.IsValid)
            {
                UpdateReviewModel(model);
                return(View(model));
            }

            var eventReviewRequest = new NewEventReviewRequest
            {
                ClubId            = club.Guid,
                CoachId           = model.MemberId,
                DifferentNextTime = model.DifferentNextTime,
                EventId           = model.EventId,
                Opportunities     = model.Opportunities,
                Squads            = model.Squads,
                Successes         = model.Successes
            };

            var response = eventService.AddEventReview(eventReviewRequest);

            if (!response.RequestIsFulfilled)
            {
                UpdateReviewModel(model);
                foreach (var error in response.Errors)
                {
                    ModelState.AddModelError("", error);
                }

                return(View(model));
            }

            return(RedirectToAction(nameof(Reviews)));
        }
コード例 #2
0
        public ActionResult NewReview(Guid eventId)
        {
            var @event = eventsQuery.GetEvent(eventId);
            var squadsNotYetReviewed = GetNotYetReviewedSquads(@event);

            if (squadsNotYetReviewed?.Count() == 0)
            {
                return(RedirectToAction(nameof(Reviews)));
            }

            var email   = User.Identity.Name;
            var members = memberQuery.GetMembersByEmail(club.Guid, email);
            var coach   = members?.FirstOrDefault(m => m.Membership == Membership.Coach);

            if (coach == null || coach.Guid.IsEmpty())
            {
                TempData[Temp_Data_Error] = "This user has not been setup as a coach. To submit reviews, add this user as a coach";
                return(RedirectToAction(nameof(Reviews)));
            }


            var model = new NewEventReviewViewModel
            {
                EventTitle           = @event.Title,
                EventDetails         = $"{@event.EventType.GetDescription()}<br/>{@event.StartDate.ToString("ddd dd-MMM-yyyy h:mm tt")}<br/>{@event.Location}<br/>{string.Join(", ", @event.Squads.Select(s => s.Name))}",
                SquadsNotYetReviewed = squadsNotYetReviewed,
                MemberId             = coach.Guid
            };

            return(View(model));
        }
コード例 #3
0
        private void UpdateReviewModel(NewEventReviewViewModel model)
        {
            var @event = eventsQuery.GetEvent(model.EventId);
            var squadsNotYetReviewed = GetNotYetReviewedSquads(@event);

            model.EventTitle           = @event.Title;
            model.EventDetails         = $"{@event.EventType.GetDescription()}<br/>{@event.StartDate.ToString("ddd dd-MMM-yyyy h:mm tt")}<br/>{@event.Location}<br/>{string.Join(", ", @event.Squads.Select(s => s.Name))}";
            model.SquadsNotYetReviewed = squadsNotYetReviewed;
        }