diff --git a/src/CalculateurMoyanne/BSN/Manager.cs b/src/CalculateurMoyanne/BSN/Manager.cs
index 5dd28d8..05916eb 100644
--- a/src/CalculateurMoyanne/BSN/Manager.cs
+++ b/src/CalculateurMoyanne/BSN/Manager.cs
@@ -112,7 +112,7 @@ namespace Bussness
{
return await maquetteDbDataManager.GetAll();
}
- // Get maquetteByName
+ // Get maquetteByName
public MaquetteModel GetMaquetteByName(string maquetteName)
{
return maquetteDbDataManager.GetDataWithName(maquetteName).Result;
diff --git a/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs b/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs
index bbd8e83..2152585 100644
--- a/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs
+++ b/src/CalculateurMoyanne/CalculateurApp/App.xaml.cs
@@ -16,14 +16,15 @@ namespace CalculateurApp
// MainPage = new NavigationPage(new HomePage());
//MainPage = new AppShell(BlocViewModel c);
- // MainPage = new MatiereView ();
+ // MainPage = new MatiereView ();
- // MainPage = new AppShell();
+ MainPage = new AppShell();
- MainPage = new HomePage();
+ // MainPage = new HomePage();
+
}
diff --git a/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj b/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj
index 6e29791..27dc2eb 100644
--- a/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj
+++ b/src/CalculateurMoyanne/CalculateurApp/CalculateurApp.csproj
@@ -69,9 +69,6 @@
MaquettePage.xaml
-
- mqt.xaml
-
diff --git a/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml b/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml
index d3f593f..b51a0e1 100644
--- a/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml
+++ b/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml
@@ -13,13 +13,13 @@
Padding="2"
RowSpacing="4"
ColumnSpacing="4">
-
-
+
-
+
@@ -52,9 +52,31 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=TapCommand}"
CommandParameter="{Binding .}" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CalculateurMoyanne/CalculateurApp/View/HomePage.xaml.cs b/src/CalculateurMoyanne/CalculateurApp/View/HomePage.xaml.cs
index 34fbce9..5de6a19 100644
--- a/src/CalculateurMoyanne/CalculateurApp/View/HomePage.xaml.cs
+++ b/src/CalculateurMoyanne/CalculateurApp/View/HomePage.xaml.cs
@@ -9,7 +9,7 @@ public partial class HomePage : TabbedPage
private void Button_Clicked(object sender, EventArgs e)
{
- Navigation.PushAsync(new BlockView());
+ Navigation.PushAsync(new MatiereView());
}
}
\ No newline at end of file
diff --git a/src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml b/src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml
index 833f096..187e6aa 100644
--- a/src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml
+++ b/src/CalculateurMoyanne/CalculateurApp/View/Maquette.xaml
@@ -12,10 +12,12 @@
RowSpacing="4"
ColumnSpacing="4">
-
-
-
-
+
+
+
@@ -57,12 +43,7 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=DeleteCommand}"
CommandParameter="{Binding .}"
/>
-
-
+
@@ -72,9 +53,30 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=TapCommand}"
CommandParameter="{Binding .}" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CalculateurMoyanne/CalculateurApp/View/MatiereView.xaml b/src/CalculateurMoyanne/CalculateurApp/View/MatiereView.xaml
index 5ad0361..6552ed0 100644
--- a/src/CalculateurMoyanne/CalculateurApp/View/MatiereView.xaml
+++ b/src/CalculateurMoyanne/CalculateurApp/View/MatiereView.xaml
@@ -7,25 +7,26 @@
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="MatiereView"
Loaded="ContentPage_Loaded">
+
+ >
+
-
+
-
+
@@ -79,8 +80,9 @@
+
+ FontAttributes="Bold"
+ TextColor="Red"/>
+
diff --git a/src/CalculateurMoyanne/CalculateurApp/View/UeView.xaml b/src/CalculateurMoyanne/CalculateurApp/View/UeView.xaml
index d255d6c..1fcc089 100644
--- a/src/CalculateurMoyanne/CalculateurApp/View/UeView.xaml
+++ b/src/CalculateurMoyanne/CalculateurApp/View/UeView.xaml
@@ -28,7 +28,6 @@
Placeholder="coef"
WidthRequest="60"
Grid.Row="1"
-
HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="AliceBlue"
@@ -88,8 +87,13 @@
+
diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs
index 3e8418d..fa7140c 100644
--- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs
+++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/BlocViewModel.cs
@@ -43,6 +43,10 @@ public partial class BlocViewModel:ObservableObject,IQueryAttributable
ue = new UE();
}
+
+
+ [ObservableProperty]
+ double moyenneUE;
[ObservableProperty]
ObservableCollection items;
[ObservableProperty]
@@ -73,15 +77,7 @@ public partial class BlocViewModel:ObservableObject,IQueryAttributable
[RelayCommand]
async Task Tapp(UE ue)
{
- // await Shell.Current.GoToAsync($"{nameof(UE)}?Nom={s}");
- //manager.SelecteBlocModel =blocModel;
- //var parametre = new Dictionary
- //{
- // {"ue",blocModel}
- //};
- //await Shell.Current.GoToAsync($"{nameof(UeView)}",parametre);
-
-
+
manager.SelectedUe = ue;
var parametre = new Dictionary
{
diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs
index 8578945..57e280c 100644
--- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs
+++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs
@@ -23,7 +23,7 @@ namespace CalculateurApp.ViewModel
public BlocModel blocModel { get; set; }
//public ReadOnlyObservableCollectionlst { get; set; }
public Manager manager { get; set; }
-
+
public MaquetteViewModel()
{ //route
@@ -75,7 +75,6 @@ namespace CalculateurApp.ViewModel
await manager.DeleteBloc(bl);
var o = await manager.GetAllBloc();
}
-
}
diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs
index bc00404..4934a42 100644
--- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs
+++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/UeViewModel.cs
@@ -33,8 +33,10 @@ namespace CalculateurApp.ViewModel
try
{
+
GEtAllMatiere();
- ma = new Matiere();
+
+
}
catch (Exception ex)
{
@@ -49,24 +51,22 @@ namespace CalculateurApp.ViewModel
set => SetProperty(ma.Nommatiere, value, ma, (u, v) => u.Nommatiere=v);
}
+
[ObservableProperty]
ObservableCollection items;
-
[ObservableProperty]
- int coefficient;
+ private string coef;
[ObservableProperty]
- int note;
+ private string note;
[RelayCommand]
async void Add()
- {
-
- Matiere m = new Matiere(ma.Note, ma.Nommatiere, ma.Coef);
+ {
+
+ Matiere m = new Matiere( int.Parse( Note), Nommatiere, int.Parse(Coef));
Items.Add(m);
await manager.AddMatiereUe(manager.SelectedUe, m);
-
-
- }
+ }
[RelayCommand]
async void Delete(Matiere bl)
{
@@ -92,20 +92,12 @@ namespace CalculateurApp.ViewModel
}
-
-
- public void ApplyQueryAttributes(IDictionary query)
+ public void ApplyQueryAttributes(IDictionary query)
{
var Ue = query["matiere"] as UE;
var MATList = Ue.Matieres;
ma.IDUEForeignKey = Ue.Id;
-
- //var bloc = query["ue"] as BlocModel;
- //var ueList = bloc.ue;
- //ue.IDForeignKey = bloc.Id;
-
-
}
}
}
diff --git a/src/CalculateurMoyanne/CalculateurEF/Entities/BlocEntity.cs b/src/CalculateurMoyanne/CalculateurEF/Entities/BlocEntity.cs
index 5363f9f..6c25d64 100644
--- a/src/CalculateurMoyanne/CalculateurEF/Entities/BlocEntity.cs
+++ b/src/CalculateurMoyanne/CalculateurEF/Entities/BlocEntity.cs
@@ -12,6 +12,7 @@ namespace CalculateurEF.Entities
#region Propriétés
public int Id { get; set; }
public string Nom { get; set; }
+
public ICollection UeEntityId { get; set; } = new List();
public int IDMaquetteFrk
diff --git a/src/CalculateurMoyanne/CalculateurEF/Entities/UEentity.cs b/src/CalculateurMoyanne/CalculateurEF/Entities/UEentity.cs
index da2090e..b3bc687 100644
--- a/src/CalculateurMoyanne/CalculateurEF/Entities/UEentity.cs
+++ b/src/CalculateurMoyanne/CalculateurEF/Entities/UEentity.cs
@@ -12,6 +12,7 @@ namespace CalculateurEF.Entities
{
public long Id { get; set; }
public int Coefficient { get; set; }
+
public string intitulé { get; set; }
public ICollection mat { get; set; }=
new List ();
diff --git a/src/CalculateurMoyanne/CalculateurEF/Migrations/20221211125750_Migrations.Designer.cs b/src/CalculateurMoyanne/CalculateurEF/Migrations/20221225120546_Migrationcalcule.Designer.cs
similarity index 92%
rename from src/CalculateurMoyanne/CalculateurEF/Migrations/20221211125750_Migrations.Designer.cs
rename to src/CalculateurMoyanne/CalculateurEF/Migrations/20221225120546_Migrationcalcule.Designer.cs
index 551f5dc..3348fbe 100644
--- a/src/CalculateurMoyanne/CalculateurEF/Migrations/20221211125750_Migrations.Designer.cs
+++ b/src/CalculateurMoyanne/CalculateurEF/Migrations/20221225120546_Migrationcalcule.Designer.cs
@@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CalculateurEF.Migrations
{
[DbContext(typeof(CalculContext))]
- [Migration("20221211125750_Migrations")]
- partial class Migrations
+ [Migration("20221225120546_Migrationcalcule")]
+ partial class Migrationcalcule
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -28,6 +28,10 @@ namespace CalculateurEF.Migrations
b.Property("IDMaquetteFrk")
.HasColumnType("INTEGER");
+ b.Property("MoyenneBloc")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
b.Property("Nom")
.IsRequired()
.HasColumnType("TEXT");
@@ -56,7 +60,7 @@ namespace CalculateurEF.Migrations
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
{
- b.Property("id")
+ b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
@@ -73,7 +77,7 @@ namespace CalculateurEF.Migrations
b.Property("Note")
.HasColumnType("INTEGER");
- b.HasKey("id");
+ b.HasKey("Id");
b.HasIndex("IDUEForeignKey");
@@ -96,6 +100,9 @@ namespace CalculateurEF.Migrations
.IsRequired()
.HasColumnType("TEXT");
+ b.Property("moyenneUe")
+ .HasColumnType("REAL");
+
b.HasKey("Id");
b.HasIndex("IDForeignKey");
diff --git a/src/CalculateurMoyanne/CalculateurEF/Migrations/20221211125750_Migrations.cs b/src/CalculateurMoyanne/CalculateurEF/Migrations/20221225120546_Migrationcalcule.cs
similarity index 92%
rename from src/CalculateurMoyanne/CalculateurEF/Migrations/20221211125750_Migrations.cs
rename to src/CalculateurMoyanne/CalculateurEF/Migrations/20221225120546_Migrationcalcule.cs
index eadfc31..e119e5d 100644
--- a/src/CalculateurMoyanne/CalculateurEF/Migrations/20221211125750_Migrations.cs
+++ b/src/CalculateurMoyanne/CalculateurEF/Migrations/20221225120546_Migrationcalcule.cs
@@ -5,7 +5,7 @@
namespace CalculateurEF.Migrations
{
///
- public partial class Migrations : Migration
+ public partial class Migrationcalcule : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
@@ -30,6 +30,7 @@ namespace CalculateurEF.Migrations
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nom = table.Column(type: "TEXT", nullable: false),
+ MoyenneBloc = table.Column(type: "TEXT", nullable: false),
IDMaquetteFrk = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
@@ -50,6 +51,7 @@ namespace CalculateurEF.Migrations
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Coefficient = table.Column(type: "INTEGER", nullable: false),
+ moyenneUe = table.Column(type: "REAL", nullable: false),
intitulé = table.Column(type: "TEXT", nullable: false),
IDForeignKey = table.Column(type: "INTEGER", nullable: false)
},
@@ -68,7 +70,7 @@ namespace CalculateurEF.Migrations
name: "matier",
columns: table => new
{
- id = table.Column(type: "INTEGER", nullable: false)
+ Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nommatiere = table.Column(type: "TEXT", nullable: false),
Note = table.Column(type: "INTEGER", nullable: false),
@@ -77,7 +79,7 @@ namespace CalculateurEF.Migrations
},
constraints: table =>
{
- table.PrimaryKey("PK_matier", x => x.id);
+ table.PrimaryKey("PK_matier", x => x.Id);
table.ForeignKey(
name: "FK_matier_Ue_IDUEForeignKey",
column: x => x.IDUEForeignKey,
diff --git a/src/CalculateurMoyanne/CalculateurEF/Migrations/CalculContextModelSnapshot.cs b/src/CalculateurMoyanne/CalculateurEF/Migrations/CalculContextModelSnapshot.cs
index 9bcde2c..67a6473 100644
--- a/src/CalculateurMoyanne/CalculateurEF/Migrations/CalculContextModelSnapshot.cs
+++ b/src/CalculateurMoyanne/CalculateurEF/Migrations/CalculContextModelSnapshot.cs
@@ -25,6 +25,10 @@ namespace CalculateurEF.Migrations
b.Property("IDMaquetteFrk")
.HasColumnType("INTEGER");
+ b.Property("MoyenneBloc")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
b.Property("Nom")
.IsRequired()
.HasColumnType("TEXT");
@@ -53,7 +57,7 @@ namespace CalculateurEF.Migrations
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
{
- b.Property("id")
+ b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
@@ -70,7 +74,7 @@ namespace CalculateurEF.Migrations
b.Property("Note")
.HasColumnType("INTEGER");
- b.HasKey("id");
+ b.HasKey("Id");
b.HasIndex("IDUEForeignKey");
@@ -93,6 +97,9 @@ namespace CalculateurEF.Migrations
.IsRequired()
.HasColumnType("TEXT");
+ b.Property("moyenneUe")
+ .HasColumnType("REAL");
+
b.HasKey("Id");
b.HasIndex("IDForeignKey");
diff --git a/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs
index c7d306c..39cc682 100644
--- a/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs
+++ b/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs
@@ -8,6 +8,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
@@ -63,9 +64,10 @@ namespace CalculateurMapping
List blocModels = new List();
using (var context = new TContext())
{
-
- var maq = await context.Maquettes.Include(m => m.Bloc)
- .SingleOrDefaultAsync(x => x.Id == maquetteModel.Id);
+ var maq = await context.Maquettes.Include(m => m.Bloc).ThenInclude(
+ x => x.UeEntityId).ThenInclude(y => y.mat)
+ .SingleOrDefaultAsync(x => x.Id == maquetteModel.Id);
+
if (maq == null) return new List();
foreach (var e in maq.Bloc)
@@ -75,13 +77,37 @@ namespace CalculateurMapping
Id = e.Id,
Nom = e.Nom,
IDMaquetteFrk = e.IDMaquetteFrk,
+ MoyenneBloc = moyenneBloc(e.UeEntityId.Select(
+ u => new UE(u.Id, u.Coefficient, u.intitulé, 0, u.mat.Select(m => new Matiere(m.Note, m.Nommatiere, m.Coef)).ToArray())
+ ).ToList())
});
}
return blocModels.AsEnumerable();
}
}
+
+ public static double moyenneBloc(List ues)
+ {
+ double moyennebolcs = 0;
+ int Coefs = 0;
+ double moyennecoefficier=0;
+ if (ues.Count > 0)
+ {
+ for(int u = 0; u < ues.Count; u++)
+ {
+ ues[u].MoyenneUe = UeDbDataManager.moyennneUE(ues[u].Matieres.ToList());
+ Coefs += ues[u].Coefficient;
+ moyennecoefficier += ues[u].MoyenneUe * ues[u].Coefficient;
+ }
+
+ moyennebolcs = moyennecoefficier / Coefs;
+
+ }
+ return moyennebolcs;
+ }
+
public async Task> GetAll()
{ //getAll
@@ -95,26 +121,7 @@ namespace CalculateurMapping
)).ToListAsync();
return temp;
}
- }//getUEdansblc
- //public async Task> GetAllUEBloc(int id)
- //{
- // List ls=new List();
- // using (var context = new TContext())
- // {
- // var temp = context.Bloc.Where(x=>x.Id==id).Select(e => e.UeEntityId).ToList();
- // foreach (var item in temp)
- // {
- // foreach (var i in item)
- // {
- // UE ue = new UE(i.Id, i.Coefficient, i.intitulé, i.mat.Select(m => new Matiere(m.id, m.Note, m.Nommatiere, m.Coef)).ToArray());
- // ls.Add(ue);
- // }
- // }
-
- // return ls;
- // }
-
- //}
+ }
public async Task GetDataWithName(string name)
{
@@ -145,22 +152,7 @@ namespace CalculateurMapping
return result;
}
- //public async Task AddUEBloc(UE data,int blocId)
- //{//addUedansbloc
- // bool resultat = false;
- // using (var context = new TContext())
- // {
- // UEentity entity = new UEentity
- // {
- // intitulé = data.Intitulé,
- // IDForeignKey = blocId,
- // };
- // context.Ue.Add(entity);
- // await context.SaveChangesAsync();
- // resultat = true;
- // return resultat;
- // }
- //}
+
public async Task AddUeBloc(BlocModel bloc, UE uE)
{
bool result = false;
diff --git a/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs
index 64845d1..158754a 100644
--- a/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs
+++ b/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs
@@ -69,15 +69,8 @@ namespace CalculateurMapping
}
-
-
}
-
-
-
-
-
//delete maquette
public async Task Delete(MaquetteModel maquette)
{
@@ -143,15 +136,99 @@ namespace CalculateurMapping
using (var context = new TContext())
{
List maquettes = new List();
- foreach (var item in context.Maquettes.Include(m => m.Bloc))
+ foreach (var item in context.Maquettes.
+ Include(m => m.Bloc).
+ ThenInclude(x=>x.UeEntityId).
+ ThenInclude(y => y.mat).ToList())
{
- // Console.WriteLine(item);
- maquettes.Add(new MaquetteModel(item.Id, item.NomMaquette,new List(),item.Bloc.Select(b=>new BlocModel(b.Nom)).ToList()));
+ maquettes.Add(new MaquetteModel
+
+ (
+ item.Id,
+ item.NomMaquette,
+ MoyenneMaquette(
+ item.Bloc.Select
+ (
+ m => new BlocModel
+ (
+ m.Nom,
+ m.Id,
+ m.UeEntityId.Select
+ (
+ u =>
+ new UE
+
+ (
+ u.Id,
+ u.Coefficient,
+ u.intitulé,
+ 0,
+ u.mat.Select
+ (m => new Matiere
+ (
+ m.Note,
+ m.Nommatiere,
+ m.Coef
+ )
+ )
+ .ToArray()
+ )
+ ).ToArray()
+
+ )
+ ).ToList()
+ )
+
+ ));
}
return maquettes;
}
}
+
+public double MoyenneMaquette(List blocModels)
+ {
+
+ double Moyennetotal = 0;
+ double MoyenneMaquette = 0;
+ int nbrbloc = 0;
+
+ if (blocModels.Count > 0)
+ {
+
+ for(int i = 0; i < blocModels.Count; i++)
+ {
+ blocModels[i].MoyenneBloc = BlocDbDataManager.moyenneBloc(blocModels[i].UEs.ToList());
+
+
+ MoyenneMaquette += blocModels[i].MoyenneBloc;
+
+
+ }
+
+ Moyennetotal = MoyenneMaquette / blocModels.Count;
+
+
+
+
+ }return Moyennetotal;
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
+
+
+
}
}
diff --git a/src/CalculateurMoyanne/CalculateurMapping/UeDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/UeDbDataManager.cs
index 5453cc6..0aed38c 100644
--- a/src/CalculateurMoyanne/CalculateurMapping/UeDbDataManager.cs
+++ b/src/CalculateurMoyanne/CalculateurMapping/UeDbDataManager.cs
@@ -95,8 +95,11 @@ namespace CalculateurMapping
e.Id,
e.Coefficient,
e.intitulé,
- e.mat.Select(j => new Matiere(j.Nommatiere)).ToArray()
+ moyennneUE(e.mat.Select(m => new Matiere(m.Note, m.Nommatiere, m.Coef)).ToList()),
+ e.mat.Select(j => new Matiere(j.Note,j.Nommatiere,j.Coef)).ToArray()
+
)).ToListAsync();
+
}
}
public Task GetDataWithName(string name)
@@ -125,9 +128,12 @@ namespace CalculateurMapping
List ls=new List();
using (var context = new TContext())
{
- var BLC = await context.Bloc.Include(m => m.UeEntityId)
- .SingleOrDefaultAsync(x => x.Id == bloc.Id);
-
+
+ var BLC = await context.Bloc.Include(
+ x => x.UeEntityId).ThenInclude(y => y.mat)
+ .SingleOrDefaultAsync(x => x.Id == bloc.Id);
+
+
if (BLC == null) return new List();
foreach (var e in BLC.UeEntityId)
{
@@ -137,12 +143,34 @@ namespace CalculateurMapping
Intitulé = e.intitulé,
Coefficient=e.Coefficient,
IDForeignKey = e.IDForeignKey,
+ MoyenneUe= moyennneUE(e.mat.Select(m => new Matiere(m.Note, m.Nommatiere, m.Coef)).ToList()),
+ // Matieres = e.mat.Select(j => new Matiere(j.Note, j.Nommatiere, j.Coef)).ToArray()
});
}
}
return ls;
- }
+ }
+ public static double moyennneUE(List matieres )
+ {
+ //(note *coef)+()+......./sum coef
+ double moyenne = 0;
+ int coefs=0;//sum de coef
+ double notecoefficiees = 0;//somme des notes *coefs
+
+ if (matieres.Count > 0)
+ {
+ for(int m=0; m< matieres.Count; m++)
+ {
+ coefs += matieres[m].Coef;
+ notecoefficiees += matieres[m].Note * matieres[m].Coef;
+
+ }
+ moyenne = notecoefficiees / coefs;
+
+ }
+ return moyenne;
+ }
}
}
diff --git a/src/CalculateurMoyanne/CalculateurStub/Stub/StubMatiere.cs b/src/CalculateurMoyanne/CalculateurStub/Stub/StubMatiere.cs
index ccccea5..7f541a7 100644
--- a/src/CalculateurMoyanne/CalculateurStub/Stub/StubMatiere.cs
+++ b/src/CalculateurMoyanne/CalculateurStub/Stub/StubMatiere.cs
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub
{
- public class StubMatiere: IDataManager
+ public class StubMatiere: IMatiereDbManager
{
private List listMatieres = new List();
@@ -67,5 +67,10 @@ namespace StubCalculateur.Stub
{
throw new NotImplementedException();
}
+
+ public Task> GetAllMatiereUE(UE ue)
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs
index bca90e3..dede0ae 100644
--- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs
+++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/BlocModel.cs
@@ -13,6 +13,8 @@ namespace ClassCalculateurMoyenne
{
[ObservableProperty]
private string nom;
+
+ public double MoyenneBloc { get; set; }
public int IDMaquetteFrk { get; set; }
public string GetNom()
{
@@ -55,6 +57,16 @@ namespace ClassCalculateurMoyenne
ue = new ReadOnlyCollection(ues);
}
+
+ //public BlocModel(string nombloc, int id, List Ux,)
+ //{
+ // Id = id;
+ // nom = nombloc;
+ // ues.AddRange(Ux);
+ // ue = new ReadOnlyCollection(ues);
+
+ //}
+
public BlocModel( List Ux)
{
@@ -67,6 +79,7 @@ namespace ClassCalculateurMoyenne
nom = nombloc;
}
+
public BlocModel(string nombloc, int id, UE[] uEs)
{
nom = nombloc;
diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs
index f836eb1..ead339d 100644
--- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs
+++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/MaquetteModel.cs
@@ -17,6 +17,7 @@ namespace ClassCalculateurMoyenne
}
private string nomMaquette;
+ public double moyenneMaquuete { get; set; }
public string NomMaquette
{
@@ -55,14 +56,22 @@ namespace ClassCalculateurMoyenne
- public MaquetteModel(int id, string nomMaquette, List u, List blc)
+ public MaquetteModel(int id, string nomMaquette, double moyennemkt, List blc)
{
Id = id;
NomMaquette = nomMaquette;
- UES = u.AsReadOnly();
+ moyenneMaquuete = moyennemkt;
BLOCS = new ReadOnlyCollection(blocs);
blocs.AddRange(blc);
+ }
+ public MaquetteModel(int id, string nomMaquette, double moyennemkt)
+ {
+ Id = id;
+ NomMaquette = nomMaquette;
+ moyenneMaquuete = moyennemkt;
+
+
}
public MaquetteModel(List u, List blocs)
{
diff --git a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs
index 5bb84a3..218f563 100644
--- a/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs
+++ b/src/CalculateurMoyanne/ClassCalculateurMoyenne/Modele/UE.cs
@@ -11,6 +11,12 @@ namespace ClassCalculateurMoyenne
private int coefficient;
[ObservableProperty]
private string intitulé;
+ [ObservableProperty]
+ private double moyenneUe;
+ public void setMoyenne(double value)
+ {
+ moyenneUe = value;
+ }
public int IDForeignKey { get; set; }
@@ -29,13 +35,14 @@ namespace ClassCalculateurMoyenne
intitulé = value;
}
- public UE ( long id, int coefficient, string intitulé,params Matiere[] matieres)
+ public UE ( long id, int coefficient, string intitulé,double moyennege,params Matiere[] matieres)
{
Id = id;
Coefficient = coefficient;
Intitulé = intitulé;
+ moyenneUe = moyennege;
Matieres = new ReadOnlyCollection(matieres);
-
+
}
public UE( List matieres, int coefficient)
@@ -50,6 +57,11 @@ namespace ClassCalculateurMoyenne
setIntitulé( intitulé);
}
public UE() { }
+ public UE(int coefficient, string intitulé,double moyennege) {
+
+ Coefficient = coefficient;
+ Intitulé = intitulé;
+ moyenneUe = moyennege; }
public UE(string intitulé, int coefficient)