public async Task <IActionResult> Index() { var services = await _repo.GetServices(); var announces = await _repo.GetAnnounces(); var userComments = await _repo.GetComments(); var homeDto = new HomeDto { Services = services.Select(a => new ServiceDto { Id = a.Id, ServiceName = a.ServiceName, ServiceDescription = a.ServiceDescription, ServicePhotoPath = a.ServicePhotoPath, ServiceSubHeader = a.ServiceSubHeader }).ToList(), Announcements = announces.Select(a => new AnnouncementDto { AnnounceContent = a.AnnounceContent, AnnounceHeader = a.AnnounceHeader, AnnouncePhotoPath = a.AnnouncePhotoPath }).ToList(), UserComments = userComments.Select(a => new UserCommentsDto { CommentText = a.CommentText, UserFullName = a.UserFullName }).ToList() }; return(View(homeDto)); }
public async Task <IActionResult> Index() { var cities = await _repo.GetKsacities(); var userComents = await _repo.GetComments(); var averageRate = await _repo.GetAverageRate(); var totalCount = await _repo.GetCommentCount(); var reviewDto = new ReviewDto { ServiceDto = new RequestedServiceDto { Ksacities = cities.Select(a => new cityDto { Id = a.Id, Name = a.Name }).ToList() }, UserComments = userComents.Select(a => new UserCommentsDto { CommentDate = a.CommentDate, CommentText = a.CommentText, Rating = a.Rating, UserEmail = a.UserEmail, UserFullName = a.UserFullName, RequestServiceId = a.RequestServiceId }).ToList(), AvaregRate = (int)averageRate, TotalRates = totalCount }; return(View(reviewDto)); }