123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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
- {
- /// <summary>
- /// Логика взаимодействия для ActivityPage.xaml
- /// </summary>
- public partial class ActivityPage : Page
- {
- ExamEntities DB = new ExamEntities();
- List<int> postsAdmin = new List<int>();
- List<usersmetrics> 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<RatingList> 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());
- }
- }
- }
|