public async Task <IActionResult> TheatrePages(int?currPage, string sortOrder) { try { var currentPage = currPage ?? 1; var totalPages = await _theatreServices.GetPageCountAsync(5); var sixTheatres = await _theatreServices.GetSixTheatresAsync(currentPage, sortOrder); var convertedTheatre = _theatreViewModelMapper.MapFrom(sixTheatres); var model = new TheatreIndexViewModel() { CurrPage = currentPage, TotalPages = totalPages, TheatreModels = convertedTheatre, }; if (totalPages > currentPage) { model.NextPage = currentPage + 1; } if (currentPage > 1) { model.PrevPage = currentPage - 1; } return(PartialView("_TheatreIndexTable", model)); } catch (Exception) { //_logger.LogError("Something went wrong"); return(RedirectToAction(nameof(Index))); } }
public async Task <IActionResult> Register(UserViewModel viewModel) { if (await _memberService.ContainPhoneAsync(viewModel.PhoneNumber)) { return(new JsonResult("fakephone")); } var dto = _userViewModelMapper.MapFrom(viewModel); await _memberService.CreateUser(dto); return(Redirect("~/Moderator/Member/OnlineUsers")); }
public async Task <IActionResult> Index(Guid reviewId) { if (reviewId == null) { return(NotFound()); } var comments = await _commentServices.GetCommentsAsync(reviewId); var commentsVm = _commentMapper.MapFrom(comments); return(View(commentsVm)); }
public async Task <IActionResult> Index(ReviewViewModel viewModel) { if (viewModel.TheatreId == null) { return(NotFound()); } var reviews = await _reviewServices.GetAllReviewsAsync(viewModel.TheatreId); var reviewsVm = _reviewMapper.MapFrom(reviews); return(View(reviewsVm)); }
public async Task <IActionResult> CreateSession(CreateSessionViewModel vm) { var dto = _createSessionViewModelMapper.MapFrom(vm); await _sessionService.Create(dto); return(Redirect("~/Moderator/Member/OnlineUsers")); }
public async Task <IActionResult> DisplaySessions(string date) { var dtos = await _sessionService.GetSessionHistoryAsync(date); var vms = _displaySessionMapper.MapFrom(dtos); return(View(vms)); }
public async Task <IActionResult> Index() { var activeUsers = await _banService.GetAllBannedUsersAsync("active"); var bannedUsers = await _banService.GetAllBannedUsersAsync("banned"); var activeUsersVM = _userMapper.MapFrom(activeUsers); var bannedUsersVM = _userMapper.MapFrom(bannedUsers); var allUsersVM = new UserCollectionsViewModel { ActiveUsers = activeUsersVM, BannedUsers = bannedUsersVM }; return(View(allUsersVM)); }
public async Task <IActionResult> Details(Guid theatreId) { if (theatreId == null) { return(NotFound()); } var theatre = await _theatreServices.GetTheatreAsync(theatreId); var theatreVm = _theatreViewModelMapper.MapFrom(theatre); var commentsAll = await _commentServices.GetCommentsAsync(theatreId); var commentsVM = _commentViewModelMapper.MapFrom(commentsAll); var reviewAll = await _reviewServices.GetAllReviewsAsync(theatreId); var reviewVm = _reviewViewModelMapper.MapFrom(reviewAll); try { var theatreAverageRating = await _theatreServices.GetAverageRatingAndNumberOfReviews(theatreId); theatreVm.AverageRating = theatreAverageRating.AverageRating; // _logger.LogInformation("Theatre average rating has been assigned "); } catch (Exception) { theatreVm.AverageRating = 0.6666; } var assignARandNumOfReviews = await _theatreServices.GetAverageRatingAndNumberOfReviews(theatreId); theatreVm.NumberOfReviews = assignARandNumOfReviews.NumberOfReviews; if (commentsVM != null) { theatreVm.CommentsVM = commentsVM; } else { theatreVm.CommentsVM = new List <CommentViewModel>(); } if (reviewVm != null) { theatreVm.ReviewsVM = reviewVm; } else { theatreVm.ReviewsVM = new List <ReviewViewModel>(); } return(View(theatreVm)); }
public async Task <IActionResult> Create(CreateDeviceViewModel vm) { var dto = _deviceViewModelMapper.MapFrom(vm); var result = await _deviceService.Create(dto); if (result) { return(new JsonResult(true)); } return(new JsonResult(false)); }
public async Task <IActionResult> Create() { var devicetypes = await _deviceTypeService.GetAllAsync(); var vm = _deviceTypeViewModelMapper.MapFrom(devicetypes); var newvm = new CreateDeviceViewModel { DeviceTypes = vm }; return(View(newvm)); }
public async Task <IActionResult> Index() { var toptheatresVM = (await CacheTopTheatres()) .Select(x => _theatreVmMapper.MapFrom(x)) .ToList(); var homeViewModel = new TheatreIndexViewModel { TheatreModels = toptheatresVM }; return(View(homeViewModel)); }
public async Task <IActionResult> CreateTheatre(TheatreViewModel theatreVM) { try { var theatreModel = _theatreVMmapper.MapFrom(theatreVM); var newlyCreatedTheatre = await _theatreService.CreateTheatreAsync(theatreModel); //_logger.LogInformation("Theatre Successfully created"); return(RedirectToAction("Catalogue", "Theatre", new { id = newlyCreatedTheatre.Id })); } catch (Exception) { //_logger.LogError("Theatre was not created,something went wrong"); return(RedirectToAction("Catalogue", "Theatre", new { area = "" })); } }
public async Task <IActionResult> Delete(int?id) { if (id == null) { return(this.NotFound()); } var offer = await this.offerService.GetOfferInfoAsync(id); if (offer == null) { return(this.NotFound()); } return(this.View(offerInfoMapper.MapFrom(offer))); }
public PurchasesCollectionViewModel MapFrom(List <Purchase> entity) => new PurchasesCollectionViewModel { Purchases = entity.Select(p => purchaseMapper.MapFrom(p)).ToList() };
public SuppliersCollectionViewModel MapFrom(List <Supplier> entity) => new SuppliersCollectionViewModel { Suppliers = entity.Select(d => supplierMapper.MapFrom(d)).ToList() };
[Authorize] // MAnager & Operator public async Task <IActionResult> Index() { var isManager = User.IsInRole("Manager"); var user = await this.userManager.GetUserAsync(User); var mails = this.emailService.ReadAllMailsFromDb(isManager, user); var model = new HomeViewModel(); List <Email> listEmails = await this.emailService.ReadAllMailsFromDb(true, user).ToListAsync(); foreach (var mail in listEmails) { mail.Unseal(); } var modelEmails = listEmails.Select(x => emailViewModelMapper.MapFrom(x)); model.NotReviewed = modelEmails.Where(s => s.Status.Text == "Not Reviewed") .OrderByDescending(x => x.DateReceived) .Take(5) .ToList(); model.New = modelEmails.Where(s => s.Status.Text == "New") .OrderByDescending(x => x.DateReceived) .Take(5) .ToList(); if (!isManager) { model.Open = modelEmails.Where(s => s.Status.Text == "Open") .Where(u => u.WorkingBy == user) .OrderBy(x => x.SetInCurrentStatusOn) .Take(5) .ToList(); model.Closed = modelEmails.Where(s => s.Status.Text == "Aproved" || s.Status.Text == "Rejected") .OrderBy(x => x.DateReceived) .Take(5) .ToList(); } else { model.Open = modelEmails.Where(s => s.Status.Text == "Open") .OrderBy(x => x.SetInCurrentStatusOn) .Take(5) .ToList(); model.Closed = modelEmails.Where(s => s.Status.Text == "Aproved" || s.Status.Text == "Rejected") .OrderBy(x => x.DateReceived) .Take(5) .ToList(); } model.UserIsManager = isManager; foreach (var mail in model.New) { mail.UserIsManager = isManager; mail.InCurrentStatusSince = DateTime.Now - mail.SetInCurrentStatusOn; } foreach (var mail in model.Open) { mail.UserIsManager = isManager; mail.InCurrentStatusSince = DateTime.Now - mail.SetInCurrentStatusOn; } foreach (var mail in model.Closed) { mail.UserIsManager = isManager; } foreach (var mail in model.NotReviewed) { mail.UserIsManager = isManager; } return(View(model)); }