using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace ModuleExam { /// /// Логика взаимодействия для ActivityPage.xaml /// public partial class ActivityPage : Page { ExamEntities DB = new ExamEntities(); List postsAdmin = new List(); List um; int UserId; public ActivityPage(int id) { InitializeComponent(); users user = new users(); user = DB.users.FirstOrDefault(x=>x.id == id); um = DB.usersmetrics.Where(x=>x.id_user == id).ToList(); postsAdmin = DB.posts.Where(x => x.id_role == 1).Select(x => x.id).ToList(); if (postsAdmin.Contains(id)) { AdminButtons.Visibility = Visibility.Visible; } SurNamPat.Text = $"{user.surname} {user.firstname} {user.patronymic}"; UserPost.Text = DB.posts.Where(x=>x.id == user.id_post).Select(x=>x.title).FirstOrDefault(); UsersCoef.ItemsSource = um; SumFinalRate(); List RateList = RatingPage.RatingCalculate(); RatingList rl1 = RateList.FirstOrDefault(x=>x.UserId == id); Place.Text = (RateList.IndexOf(rl1)+1).ToString(); UserId = id; } public void SumFinalRate() { double finalRate = 0; foreach(usersmetrics u in um) { finalRate += (double)u.coefficient; } FinalRate.Text = finalRate.ToString(); } private void ToRatePage(object sender, RoutedEventArgs e) { MainFrame.MFrame.Navigate(new RatingPage(UserId)); } private void ToUserDataPage(object sender, RoutedEventArgs e) { MainFrame.MFrame.Navigate(new UserData(UserId)); } private void Exit(object sender, RoutedEventArgs e) { MainFrame.MFrame.Navigate(new Auth()); } } }