示例#1
0
        public async Task <ActionResult> ServicePage(Review review)
        {
            Service service = repository.Services.Where(s => s.ServiceId == review.ServiceId).FirstOrDefault();

            if (ModelState.IsValid)
            {
                GeneralUser user = await GetCurrentUserAsync();

                review.UserName = user.FirstName + " " + user.LastName;
                review.UserId   = user.Id;
                review.Date     = DateTime.Now;
                repository.AddReview(review);
            }
            List <Review> reviews = (from rev in repository.Reviews
                                     where rev.ServiceId == review.ServiceId
                                     orderby rev.Date descending
                                     select rev).ToList();

            service.AddReviews(reviews);
            return(View(service));
        }