public IActionResult Panel() { var currentUserReservation = _reservationService.Get().OrderByDescending(x => x.ArriveDate) .FirstOrDefault(x => x.UserId == User.FindFirstValue(ClaimTypes.UserData)); var model = new PanelModel { Reservations = _reservationService.Get().Count(x => x.DepartureDate.ToLocalTime() > DateTime.UtcNow), }; if (_complaintsService.Get().Any()) { model.Complaints = new List <ComplaintsModel>(); foreach (var complaint in _complaintsService.Get()) { model.Complaints.Add(new ComplaintsModel { DateOfCreation = complaint.DateOfCreation.ToLocalTime(), Department = Enum.Parse <Departments>(complaint.Department), Priority = Enum.Parse <Priority>(complaint.Priority), Description = complaint.Description, Title = complaint.Title, EmailAddress = complaint.EmailAddress, State = complaint.State, UserId = complaint.UserId, Id = complaint.Id }); } } if (currentUserReservation != null) { model.CurrentUserReservationModel = new ReservationModel { ArriveDate = currentUserReservation.ArriveDate, DepartureDate = currentUserReservation.DepartureDate, EmailAddress = currentUserReservation.EmailAddress, PhoneNumber = currentUserReservation.PhoneNumber }; } return(View(model)); }
/// <summary> /// Fetch all complaints from the database and return them in a model /// </summary> /// <returns></returns> public IActionResult Complainments() { var complaints = _complaintsService.Get(); var model = new List <ComplaintsModel>(); model.AddRange(complaints.Select(complaint => new ComplaintsModel { DateOfCreation = complaint.DateOfCreation.ToLocalTime(), Department = Enum.Parse <Departments>(complaint.Department), Priority = Enum.Parse <Priority>(complaint.Priority), Description = complaint.Description, Title = complaint.Title, EmailAddress = complaint.EmailAddress, State = complaint.State, UserId = complaint.UserId, Id = complaint.Id })); return(View(model)); }