PROJET
continuous-integration/drone/push Build is failing Details

master
etudiant 2 years ago
parent 7852d2bd41
commit d6c84d1af1

@ -20,10 +20,11 @@ namespace CalculateurApp
// MainPage = new AppShell(); MainPage = new AppShell();
MainPage = new HomePage(); // MainPage = new HomePage();
} }

@ -69,9 +69,6 @@
<Compile Update="View\MaquettePage.xaml.cs"> <Compile Update="View\MaquettePage.xaml.cs">
<DependentUpon>MaquettePage.xaml</DependentUpon> <DependentUpon>MaquettePage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="View\mqt.xaml.cs">
<DependentUpon>mqt.xaml</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -13,13 +13,13 @@
Padding="2" Padding="2"
RowSpacing="4" RowSpacing="4"
ColumnSpacing="4"> ColumnSpacing="4">
<Entry Placeholder="Ajout de BLOC DANS LA MAQUETTE" <Entry Placeholder="AJOUT DE BLOC DANS LA MAQUETTE"
Grid.Row="1" BackgroundColor="AliceBlue" Grid.Row="1" BackgroundColor="AliceBlue"
Text="{Binding Nom}" Text="{Binding Nom}"
x:Name="ajt" x:Name="ajt"
TextColor="Black" TextColor="Black"
/> />
<Button x:Name="Afer" Text="Modifier" Grid.Row="1" Grid.Column="1" HorizontalOptions="End" VerticalOptions="End" WidthRequest="80" Command="{Binding GetAllBlocCommand}" > </Button>
<Button <Button
Command="{Binding AddCommand}" Command="{Binding AddCommand}"
Text="ajouter" Text="ajouter"
@ -42,7 +42,7 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=DeleteCommand}" Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=DeleteCommand}"
CommandParameter="{Binding .}" CommandParameter="{Binding .}"
/> />
<SwipeItem Text="AFFICHER" BackgroundColor="BlueViolet"></SwipeItem>
</SwipeItems> </SwipeItems>
</SwipeView.RightItems> </SwipeView.RightItems>
<Grid Padding="0"> <Grid Padding="0">
@ -52,9 +52,31 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=TapCommand}" Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=TapCommand}"
CommandParameter="{Binding .}" /> CommandParameter="{Binding .}" />
</Frame.GestureRecognizers> </Frame.GestureRecognizers>
<Grid Padding="10" ColumnSpacing="40">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Nom}" <Label Text="{Binding Nom}"
FontSize="10" TextColor="Black" FontSize="Header" TextColor="Black"
/> />
<Label Text="{Binding MoyenneBloc}"
Grid.Row="1"
Grid.Column="2"
TextColor="Blue"
TextDecorations="Underline"
FontSize="Header"
/>
</Grid>
</Frame> </Frame>
</Grid> </Grid>
</SwipeView> </SwipeView>

@ -9,7 +9,7 @@ public partial class HomePage : TabbedPage
private void Button_Clicked(object sender, EventArgs e) private void Button_Clicked(object sender, EventArgs e)
{ {
Navigation.PushAsync(new BlockView()); Navigation.PushAsync(new MatiereView());
} }
} }

@ -12,10 +12,12 @@
RowSpacing="4" RowSpacing="4"
ColumnSpacing="4"> ColumnSpacing="4">
<Entry Placeholder="Ajout de LA MAQUETTE" <Entry Placeholder="veuillez saisir le nom de la maquette"
Grid.Row="1" BackgroundColor="AliceBlue" Grid.Row="1" BackgroundColor="AliceBlue"
Text="{Binding NomMaquette }" Text="{Binding NomMaquette }"
TextColor="Black" TextColor="Black"
PlaceholderColor="Gray"
/> />
<Button <Button
Command="{Binding AddCommand}" Command="{Binding AddCommand}"
@ -28,25 +30,9 @@
> >
</Button> </Button>
<Button Command="{Binding AddCommand}"
Text="Modifier"
Grid.Row="1"
Grid.Column="2"
HorizontalOptions="End"
VerticalOptions="End"
WidthRequest="85"></Button>
<!--<Button
Command=" {Binding GetAllMaquetteCommand}"
Text="afficher"
Grid.Row="2"
Grid.Column="1"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="100">
</Button>--> <CollectionView Grid.Row="3" Grid.ColumnSpan="1" ItemsSource="{Binding Items}" SelectionMode="None" BackgroundColor="AliceBlue" >
<CollectionView Grid.Row="3" Grid.ColumnSpan="1" ItemsSource="{Binding Items}" SelectionMode="None" BackgroundColor="White">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:MaquetteModel }"> <DataTemplate x:DataType="{x:Type model:MaquetteModel }">
<SwipeView> <SwipeView>
@ -57,12 +43,7 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=DeleteCommand}" Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=DeleteCommand}"
CommandParameter="{Binding .}" CommandParameter="{Binding .}"
/> />
<SwipeItem Text="AFFICHER"
BackgroundColor="BlueViolet"
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}},Path=GetAllMaquetteCommand}"
CommandParameter="{Binding .}"
></SwipeItem>
<SwipeItem Text="MODIFIER Bloc" BackgroundColor="Beige"></SwipeItem>
</SwipeItems> </SwipeItems>
</SwipeView.RightItems> </SwipeView.RightItems>
<Grid Padding="0"> <Grid Padding="0">
@ -72,9 +53,30 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=TapCommand}" Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=TapCommand}"
CommandParameter="{Binding .}" /> CommandParameter="{Binding .}" />
</Frame.GestureRecognizers> </Frame.GestureRecognizers>
<Grid Padding="10" ColumnSpacing="40">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Text="{Binding NomMaquette}" <Label Text="{Binding NomMaquette}"
FontSize="10" TextColor="Black" FontSize="Header" TextColor="Black"
/>
<Label Text="{Binding moyenneMaquuete}"
Grid.Row="1"
Grid.Column="2"
FontSize="Header" TextColor="Red"
/> />
</Grid>
</Frame> </Frame>
</Grid> </Grid>
</SwipeView> </SwipeView>

@ -7,6 +7,7 @@
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne" xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="MatiereView" Title="MatiereView"
Loaded="ContentPage_Loaded"> Loaded="ContentPage_Loaded">
<Grid RowDefinitions="100 ,Auto,*" <Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".225*,.225*" ColumnDefinitions=".225*,.225*"
Padding="10" Padding="10"
@ -16,7 +17,7 @@
> >
<Label Text=" Note:" VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150" ></Label> <Label Text=" Note:" VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150" ></Label>
<Entry Text="{Binding ma.Note}" Placeholder="note" HorizontalOptions="End" <Entry Text="{Binding Note}" Placeholder="note" HorizontalOptions="End"
VerticalOptions="Center" WidthRequest="60" ></Entry> VerticalOptions="Center" WidthRequest="60" ></Entry>
<Label Grid.Column="2" Text="/" HorizontalOptions="Center" <Label Grid.Column="2" Text="/" HorizontalOptions="Center"
VerticalOptions="Center" WidthRequest="60"></Label> VerticalOptions="Center" WidthRequest="60"></Label>
@ -24,8 +25,8 @@
VerticalOptions="Center"></Label> VerticalOptions="Center"></Label>
<Label Text="coefficent" Grid.Row="1" <Label Text="coefficent" Grid.Row="1"
VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150"></Label> VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150"></Label>
<Entry Grid.Row="1" Text="{Binding ma.Coef}" <Entry Grid.Row="1" Text="{Binding Coef}" IsEnabled="True" Placeholder="COEFFICIENT"
VerticalOptions="Center" HorizontalOptions="End" WidthRequest="60" ></Entry> VerticalOptions="Center" HorizontalOptions="End" WidthRequest="60"/>
<Label Text="Nom de la Matiere" Grid.Row="1" Grid.Column="2" HorizontalOptions="Center"></Label> <Label Text="Nom de la Matiere" Grid.Row="1" Grid.Column="2" HorizontalOptions="Center"></Label>
<Entry Grid.Column="3" Placeholder="nom" Grid.Row="1" Text="{Binding Nommatiere}" HorizontalOptions="End"> <Entry Grid.Column="3" Placeholder="nom" Grid.Row="1" Text="{Binding Nommatiere}" HorizontalOptions="End">
@ -79,8 +80,9 @@
<Label Grid.Column="2" <Label Grid.Column="2"
Grid.Row="1" Grid.Row="1"
Text="{Binding Note}" Text="{Binding Note}"
TextColor="Blue"
FontAttributes="Bold" /> FontAttributes="Bold"
TextColor="Red"/>
<Label Grid.Column="3" <Label Grid.Column="3"
Grid.Row="1" Grid.Row="1"
Text="20" Text="20"
@ -91,6 +93,7 @@
Text="{Binding Coef}" Text="{Binding Coef}"
TextColor="Blue" TextColor="Blue"
FontAttributes="Bold" /> FontAttributes="Bold" />
</Grid> </Grid>
</Frame> </Frame>
</Grid> </Grid>

@ -28,7 +28,6 @@
Placeholder="coef" Placeholder="coef"
WidthRequest="60" WidthRequest="60"
Grid.Row="1" Grid.Row="1"
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Center" VerticalOptions="Center"
BackgroundColor="AliceBlue" BackgroundColor="AliceBlue"
@ -88,8 +87,13 @@
<Label Grid.Column="3" <Label Grid.Column="3"
Grid.Row="1" Grid.Row="1"
Text="{Binding Coefficient}" Text="{Binding Coefficient}"
TextColor="Blue" TextColor="Red"
FontAttributes="Bold" /> FontAttributes="Bold" />
<Label Text="{Binding MoyenneUe}"
Grid.Row="1"
Grid.Column="4"
FontSize="10" TextColor="Blue"
/>
</Grid> </Grid>
</Frame> </Frame>

@ -43,6 +43,10 @@ public partial class BlocViewModel:ObservableObject,IQueryAttributable
ue = new UE(); ue = new UE();
} }
[ObservableProperty]
double moyenneUE;
[ObservableProperty] [ObservableProperty]
ObservableCollection<UE> items; ObservableCollection<UE> items;
[ObservableProperty] [ObservableProperty]
@ -73,14 +77,6 @@ public partial class BlocViewModel:ObservableObject,IQueryAttributable
[RelayCommand] [RelayCommand]
async Task Tapp(UE ue) async Task Tapp(UE ue)
{ {
// await Shell.Current.GoToAsync($"{nameof(UE)}?Nom={s}");
//manager.SelecteBlocModel =blocModel;
//var parametre = new Dictionary<string, Object>
//{
// {"ue",blocModel}
//};
//await Shell.Current.GoToAsync($"{nameof(UeView)}",parametre);
manager.SelectedUe = ue; manager.SelectedUe = ue;
var parametre = new Dictionary<string, Object> var parametre = new Dictionary<string, Object>

@ -76,7 +76,6 @@ namespace CalculateurApp.ViewModel
var o = await manager.GetAllBloc(); var o = await manager.GetAllBloc();
} }
} }
[RelayCommand] [RelayCommand]

@ -33,8 +33,10 @@ namespace CalculateurApp.ViewModel
try try
{ {
GEtAllMatiere(); GEtAllMatiere();
ma = new Matiere();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -49,23 +51,21 @@ namespace CalculateurApp.ViewModel
set => SetProperty(ma.Nommatiere, value, ma, (u, v) => u.Nommatiere=v); set => SetProperty(ma.Nommatiere, value, ma, (u, v) => u.Nommatiere=v);
} }
[ObservableProperty] [ObservableProperty]
ObservableCollection<Matiere> items; ObservableCollection<Matiere> items;
[ObservableProperty] [ObservableProperty]
int coefficient; private string coef;
[ObservableProperty] [ObservableProperty]
int note; private string note;
[RelayCommand] [RelayCommand]
async void Add() 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); Items.Add(m);
await manager.AddMatiereUe(manager.SelectedUe, m); await manager.AddMatiereUe(manager.SelectedUe, m);
} }
[RelayCommand] [RelayCommand]
async void Delete(Matiere bl) async void Delete(Matiere bl)
@ -92,20 +92,12 @@ namespace CalculateurApp.ViewModel
} }
public void ApplyQueryAttributes(IDictionary<string, object> query) public void ApplyQueryAttributes(IDictionary<string, object> query)
{ {
var Ue = query["matiere"] as UE; var Ue = query["matiere"] as UE;
var MATList = Ue.Matieres; var MATList = Ue.Matieres;
ma.IDUEForeignKey = Ue.Id; ma.IDUEForeignKey = Ue.Id;
//var bloc = query["ue"] as BlocModel;
//var ueList = bloc.ue;
//ue.IDForeignKey = bloc.Id;
} }
} }
} }

@ -12,6 +12,7 @@ namespace CalculateurEF.Entities
#region Propriétés #region Propriétés
public int Id { get; set; } public int Id { get; set; }
public string Nom { get; set; } public string Nom { get; set; }
public ICollection<UEentity> UeEntityId { get; set; } = new List<UEentity>(); public ICollection<UEentity> UeEntityId { get; set; } = new List<UEentity>();
public int IDMaquetteFrk public int IDMaquetteFrk

@ -12,6 +12,7 @@ namespace CalculateurEF.Entities
{ {
public long Id { get; set; } public long Id { get; set; }
public int Coefficient { get; set; } public int Coefficient { get; set; }
public string intitulé { get; set; } public string intitulé { get; set; }
public ICollection<MatiereEntity> mat { get; set; }= public ICollection<MatiereEntity> mat { get; set; }=
new List<MatiereEntity> (); new List<MatiereEntity> ();

@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CalculateurEF.Migrations namespace CalculateurEF.Migrations
{ {
[DbContext(typeof(CalculContext))] [DbContext(typeof(CalculContext))]
[Migration("20221211125750_Migrations")] [Migration("20221225120546_Migrationcalcule")]
partial class Migrations partial class Migrationcalcule
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -28,6 +28,10 @@ namespace CalculateurEF.Migrations
b.Property<int>("IDMaquetteFrk") b.Property<int>("IDMaquetteFrk")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("MoyenneBloc")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Nom") b.Property<string>("Nom")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@ -56,7 +60,7 @@ namespace CalculateurEF.Migrations
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b => modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
{ {
b.Property<long>("id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -73,7 +77,7 @@ namespace CalculateurEF.Migrations
b.Property<int>("Note") b.Property<int>("Note")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.HasKey("id"); b.HasKey("Id");
b.HasIndex("IDUEForeignKey"); b.HasIndex("IDUEForeignKey");
@ -96,6 +100,9 @@ namespace CalculateurEF.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<double>("moyenneUe")
.HasColumnType("REAL");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("IDForeignKey"); b.HasIndex("IDForeignKey");

@ -5,7 +5,7 @@
namespace CalculateurEF.Migrations namespace CalculateurEF.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class Migrations : Migration public partial class Migrationcalcule : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@ -30,6 +30,7 @@ namespace CalculateurEF.Migrations
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Nom = table.Column<string>(type: "TEXT", nullable: false), Nom = table.Column<string>(type: "TEXT", nullable: false),
MoyenneBloc = table.Column<string>(type: "TEXT", nullable: false),
IDMaquetteFrk = table.Column<int>(type: "INTEGER", nullable: false) IDMaquetteFrk = table.Column<int>(type: "INTEGER", nullable: false)
}, },
constraints: table => constraints: table =>
@ -50,6 +51,7 @@ namespace CalculateurEF.Migrations
Id = table.Column<long>(type: "INTEGER", nullable: false) Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Coefficient = table.Column<int>(type: "INTEGER", nullable: false), Coefficient = table.Column<int>(type: "INTEGER", nullable: false),
moyenneUe = table.Column<double>(type: "REAL", nullable: false),
intitulé = table.Column<string>(type: "TEXT", nullable: false), intitulé = table.Column<string>(type: "TEXT", nullable: false),
IDForeignKey = table.Column<int>(type: "INTEGER", nullable: false) IDForeignKey = table.Column<int>(type: "INTEGER", nullable: false)
}, },
@ -68,7 +70,7 @@ namespace CalculateurEF.Migrations
name: "matier", name: "matier",
columns: table => new columns: table => new
{ {
id = table.Column<long>(type: "INTEGER", nullable: false) Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Nommatiere = table.Column<string>(type: "TEXT", nullable: false), Nommatiere = table.Column<string>(type: "TEXT", nullable: false),
Note = table.Column<int>(type: "INTEGER", nullable: false), Note = table.Column<int>(type: "INTEGER", nullable: false),
@ -77,7 +79,7 @@ namespace CalculateurEF.Migrations
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_matier", x => x.id); table.PrimaryKey("PK_matier", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_matier_Ue_IDUEForeignKey", name: "FK_matier_Ue_IDUEForeignKey",
column: x => x.IDUEForeignKey, column: x => x.IDUEForeignKey,

@ -25,6 +25,10 @@ namespace CalculateurEF.Migrations
b.Property<int>("IDMaquetteFrk") b.Property<int>("IDMaquetteFrk")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("MoyenneBloc")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Nom") b.Property<string>("Nom")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@ -53,7 +57,7 @@ namespace CalculateurEF.Migrations
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b => modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
{ {
b.Property<long>("id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -70,7 +74,7 @@ namespace CalculateurEF.Migrations
b.Property<int>("Note") b.Property<int>("Note")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.HasKey("id"); b.HasKey("Id");
b.HasIndex("IDUEForeignKey"); b.HasIndex("IDUEForeignKey");
@ -93,6 +97,9 @@ namespace CalculateurEF.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<double>("moyenneUe")
.HasColumnType("REAL");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("IDForeignKey"); b.HasIndex("IDForeignKey");

@ -8,6 +8,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Metadata;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -63,9 +64,10 @@ namespace CalculateurMapping
List<BlocModel> blocModels = new List<BlocModel>(); List<BlocModel> blocModels = new List<BlocModel>();
using (var context = new TContext()) using (var context = new TContext())
{ {
var maq = await context.Maquettes.Include(m => m.Bloc).ThenInclude(
var maq = await context.Maquettes.Include(m => m.Bloc) x => x.UeEntityId).ThenInclude(y => y.mat)
.SingleOrDefaultAsync(x => x.Id == maquetteModel.Id); .SingleOrDefaultAsync(x => x.Id == maquetteModel.Id);
if (maq == null) return new List<BlocModel>(); if (maq == null) return new List<BlocModel>();
foreach (var e in maq.Bloc) foreach (var e in maq.Bloc)
@ -75,6 +77,9 @@ namespace CalculateurMapping
Id = e.Id, Id = e.Id,
Nom = e.Nom, Nom = e.Nom,
IDMaquetteFrk = e.IDMaquetteFrk, 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<BlocModel>(); return blocModels.AsEnumerable<BlocModel>();
@ -83,6 +88,27 @@ namespace CalculateurMapping
} }
public static double moyenneBloc(List<UE> 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<CalculContext>.moyennneUE(ues[u].Matieres.ToList());
Coefs += ues[u].Coefficient;
moyennecoefficier += ues[u].MoyenneUe * ues[u].Coefficient;
}
moyennebolcs = moyennecoefficier / Coefs;
}
return moyennebolcs;
}
public async Task<List<BlocModel>> GetAll() public async Task<List<BlocModel>> GetAll()
{ //getAll { //getAll
using (var context = new TContext()) using (var context = new TContext())
@ -95,26 +121,7 @@ namespace CalculateurMapping
)).ToListAsync(); )).ToListAsync();
return temp; return temp;
} }
}//getUEdansblc }
//public async Task<List<UE>> GetAllUEBloc(int id)
//{
// List<UE> ls=new List<UE>();
// 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<BlocModel> GetDataWithName(string name) public async Task<BlocModel> GetDataWithName(string name)
{ {
@ -145,22 +152,7 @@ namespace CalculateurMapping
return result; return result;
} }
//public async Task<bool> 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<bool> AddUeBloc(BlocModel bloc, UE uE) public async Task<bool> AddUeBloc(BlocModel bloc, UE uE)
{ {
bool result = false; bool result = false;

@ -69,15 +69,8 @@ namespace CalculateurMapping
} }
} }
//delete maquette //delete maquette
public async Task<bool> Delete(MaquetteModel maquette) public async Task<bool> Delete(MaquetteModel maquette)
{ {
@ -143,15 +136,99 @@ namespace CalculateurMapping
using (var context = new TContext()) using (var context = new TContext())
{ {
List<MaquetteModel> maquettes = new List<MaquetteModel>(); List<MaquetteModel> maquettes = new List<MaquetteModel>();
foreach (var item in context.Maquettes.Include(m => m.Bloc)) foreach (var item in context.Maquettes.
{ Include(m => m.Bloc).
// Console.WriteLine(item); ThenInclude(x=>x.UeEntityId).
maquettes.Add(new MaquetteModel(item.Id, item.NomMaquette,new List<UE>(),item.Bloc.Select(b=>new BlocModel(b.Nom)).ToList())); ThenInclude(y => y.mat).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; return maquettes;
} }
} }
public double MoyenneMaquette(List<BlocModel> 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<CalculContext>.moyenneBloc(blocModels[i].UEs.ToList());
MoyenneMaquette += blocModels[i].MoyenneBloc;
}
Moyennetotal = MoyenneMaquette / blocModels.Count;
}return Moyennetotal;
}
} }
} }

@ -95,8 +95,11 @@ namespace CalculateurMapping
e.Id, e.Id,
e.Coefficient, e.Coefficient,
e.intitulé, 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(); )).ToListAsync();
} }
} }
public Task<UE> GetDataWithName(string name) public Task<UE> GetDataWithName(string name)
@ -125,9 +128,12 @@ namespace CalculateurMapping
List<UE> ls=new List<UE>(); List<UE> ls=new List<UE>();
using (var context = new TContext()) using (var context = new TContext())
{ {
var BLC = await context.Bloc.Include(m => m.UeEntityId)
var BLC = await context.Bloc.Include(
x => x.UeEntityId).ThenInclude(y => y.mat)
.SingleOrDefaultAsync(x => x.Id == bloc.Id); .SingleOrDefaultAsync(x => x.Id == bloc.Id);
if (BLC == null) return new List<UE>(); if (BLC == null) return new List<UE>();
foreach (var e in BLC.UeEntityId) foreach (var e in BLC.UeEntityId)
{ {
@ -137,6 +143,8 @@ namespace CalculateurMapping
Intitulé = e.intitulé, Intitulé = e.intitulé,
Coefficient=e.Coefficient, Coefficient=e.Coefficient,
IDForeignKey = e.IDForeignKey, 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()
}); });
} }
@ -144,5 +152,25 @@ namespace CalculateurMapping
return ls; return ls;
} }
public static double moyennneUE(List<Matiere> 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;
}
} }
} }

@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub namespace StubCalculateur.Stub
{ {
public class StubMatiere: IDataManager<Matiere> public class StubMatiere: IMatiereDbManager
{ {
private List<Matiere> listMatieres = new List<Matiere>(); private List<Matiere> listMatieres = new List<Matiere>();
@ -67,5 +67,10 @@ namespace StubCalculateur.Stub
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<IEnumerable<Matiere>> GetAllMatiereUE(UE ue)
{
throw new NotImplementedException();
}
} }
} }

@ -13,6 +13,8 @@ namespace ClassCalculateurMoyenne
{ {
[ObservableProperty] [ObservableProperty]
private string nom; private string nom;
public double MoyenneBloc { get; set; }
public int IDMaquetteFrk { get; set; } public int IDMaquetteFrk { get; set; }
public string GetNom() public string GetNom()
{ {
@ -55,6 +57,16 @@ namespace ClassCalculateurMoyenne
ue = new ReadOnlyCollection<UE>(ues); ue = new ReadOnlyCollection<UE>(ues);
} }
//public BlocModel(string nombloc, int id, List<UE> Ux,)
//{
// Id = id;
// nom = nombloc;
// ues.AddRange(Ux);
// ue = new ReadOnlyCollection<UE>(ues);
//}
public BlocModel( List<UE> Ux) public BlocModel( List<UE> Ux)
{ {
@ -67,6 +79,7 @@ namespace ClassCalculateurMoyenne
nom = nombloc; nom = nombloc;
} }
public BlocModel(string nombloc, int id, UE[] uEs) public BlocModel(string nombloc, int id, UE[] uEs)
{ {
nom = nombloc; nom = nombloc;

@ -17,6 +17,7 @@ namespace ClassCalculateurMoyenne
} }
private string nomMaquette; private string nomMaquette;
public double moyenneMaquuete { get; set; }
public string NomMaquette public string NomMaquette
{ {
@ -55,14 +56,22 @@ namespace ClassCalculateurMoyenne
public MaquetteModel(int id, string nomMaquette, List<UE> u, List<BlocModel> blc) public MaquetteModel(int id, string nomMaquette, double moyennemkt, List<BlocModel> blc)
{ {
Id = id; Id = id;
NomMaquette = nomMaquette; NomMaquette = nomMaquette;
UES = u.AsReadOnly(); moyenneMaquuete = moyennemkt;
BLOCS = new ReadOnlyCollection<BlocModel>(blocs); BLOCS = new ReadOnlyCollection<BlocModel>(blocs);
blocs.AddRange(blc); blocs.AddRange(blc);
}
public MaquetteModel(int id, string nomMaquette, double moyennemkt)
{
Id = id;
NomMaquette = nomMaquette;
moyenneMaquuete = moyennemkt;
} }
public MaquetteModel(List<UE> u, List<BlocModel> blocs) public MaquetteModel(List<UE> u, List<BlocModel> blocs)
{ {

@ -11,6 +11,12 @@ namespace ClassCalculateurMoyenne
private int coefficient; private int coefficient;
[ObservableProperty] [ObservableProperty]
private string intitulé; private string intitulé;
[ObservableProperty]
private double moyenneUe;
public void setMoyenne(double value)
{
moyenneUe = value;
}
public int IDForeignKey { get; set; } public int IDForeignKey { get; set; }
@ -29,11 +35,12 @@ namespace ClassCalculateurMoyenne
intitulé = value; 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; Id = id;
Coefficient = coefficient; Coefficient = coefficient;
Intitulé = intitulé; Intitulé = intitulé;
moyenneUe = moyennege;
Matieres = new ReadOnlyCollection<Matiere>(matieres); Matieres = new ReadOnlyCollection<Matiere>(matieres);
} }
@ -50,6 +57,11 @@ namespace ClassCalculateurMoyenne
setIntitulé( intitulé); setIntitulé( intitulé);
} }
public UE() { } public UE() { }
public UE(int coefficient, string intitulé,double moyennege) {
Coefficient = coefficient;
Intitulé = intitulé;
moyenneUe = moyennege; }
public UE(string intitulé, int coefficient) public UE(string intitulé, int coefficient)

Loading…
Cancel
Save