master
etudiant 3 years ago
parent ee637b14a5
commit bc1503ec10

@ -3,15 +3,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClassCalculateurMoyenne;
namespace BSN
namespace Bussness
{
public interface IDataManager<Data>
{
Task<bool> Add(Data data);
Task<bool> Delete(Data data);
Task<bool> Update(Data data);
Task<Data> GetDataWithName(string name);
Task<IEnumerable<Data>> GetAll();
Task<List<Data>> GetAll();
Task<bool> AddUEBloc(UE data, int blocId);
}
}

@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BSN
namespace Bussness
{
public class Manager
{
@ -41,6 +41,7 @@ namespace BSN
this.maquetteDbDataManager = maquettemanager;
maquette = new ReadOnlyCollection<MaquetteModel>(maquettes);
}
public Manager(IDataManager<BlocModel>blocmanager)
{
this.blocDbDataManager = blocmanager;
@ -72,6 +73,7 @@ namespace BSN
#endregion
#region Methodes
//Add Maquette
public Task<bool> AddMaquette(MaquetteModel maqt)
{
@ -80,10 +82,10 @@ namespace BSN
return Task.FromResult(false);
}
return maquetteDbDataManager.Add(maqt);
return maquetteDbDataManager.Add(maqt);
}
//Delete Maquette
public async Task<bool> Deletemqt(MaquetteModel maqt)
{
if (maquetteDbDataManager == null)
@ -92,7 +94,7 @@ namespace BSN
}
return await maquetteDbDataManager.Delete(maqt);
}
//Update Maquette
public async Task<bool> UpdateMaquette(MaquetteModel maqt)
{
if (maquetteDbDataManager == null)
@ -101,12 +103,66 @@ namespace BSN
}
return await maquetteDbDataManager.Update(maqt);
}
public async Task<IEnumerable<MaquetteModel>> GetAllMaquette()
// GEt all Maquette
public async Task<List<MaquetteModel>> GetAllMaquette()
{
return await maquetteDbDataManager.GetAll();
}
// Get maquetteByName
public MaquetteModel GetMaquetteByName(string maquetteName)
{
return maquetteDbDataManager.GetDataWithName(maquetteName).Result;
}
// add bloc
public Task<bool> AddBloc(BlocModel bloc)
{
var response = blocDbDataManager == null;
if (response)
{
return Task.FromResult(false);
}
return blocDbDataManager.Add(bloc);
}
//public Task<bool> Adddansbloc(BlocModel bloc)
//{
// if (blocDbDataManager == null)
// {
// return Task.FromResult(false);
// }
// return blocDbDataManager.Add(bloc);
//}
//Delete bloc
public async Task<bool> DeleteBloc(BlocModel bl)
{
if (BlocDbDataManager == null)
{
return false;
}
return await BlocDbDataManager.Delete(bl);
}
//public async Task<bool> DeleteBlocById(int id)
//{
//}
//Update bloc
public async Task<bool> UpdateBloc(BlocModel bl)
{
if (BlocDbDataManager == null)
{
return false;
}
return await BlocDbDataManager.Update(bl);
}
//GetAllbloc
public async Task<IEnumerable<BlocModel>> GetAllBloc()
{
return await BlocDbDataManager.GetAll();
}
#endregion
}
#endregion
}

@ -10,11 +10,13 @@ namespace CalculateurApp
{
InitializeComponent();
// MainPage = new NavigationPage(new HomePage());
// MainPage = new NavigationPage(new HomePage());
//MainPage = new AppShell(BlocViewModel c);
MainPage = new Maquette ();
// MainPage = new Start();
// MainPage = new EXE ();
MainPage = new AppShell();
// MainPage = new Maquette();
}
}
}

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="CalculateurApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CalculateurApp"
xmlns:local="clr-namespace:CalculateurApp.View"
Shell.FlyoutBehavior="Disabled">
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
ContentTemplate="{DataTemplate local:AjtMaquette}"
Route="AjtMaquette" />
</Shell>

@ -7,7 +7,7 @@ namespace CalculateurApp
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(Start), typeof(Start));
Routing.RegisterRoute(nameof(BlockView), typeof(BlockView));
}
}
}

@ -0,0 +1,19 @@
using System;
using CalculateurEF.Context;
using Microsoft.EntityFrameworkCore;
namespace CalculateurApp
{
public class CalculDbMaui:CalculContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source={ DataBase_constante.DatabasePath}");
}
}
}
}

@ -38,10 +38,6 @@
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
@ -50,12 +46,20 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BSN\Bussness.csproj" />
<ProjectReference Include="..\CalculateurEF\CalculateurEF.csproj" />
<ProjectReference Include="..\ClassCalculateurMoyenne\ClassCalculateurMoyenne.csproj" />
<ProjectReference Include="..\CalculateurMapping\CalculateurMapping.csproj" />
</ItemGroup>
<ItemGroup>
@ -65,6 +69,9 @@
<Compile Update="View\MaquettePage.xaml.cs">
<DependentUpon>MaquettePage.xaml</DependentUpon>
</Compile>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="View\mqt.xaml.cs">
<DependentUpon>mqt.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
@ -89,6 +96,24 @@
<MauiXaml Update="View\UEPage1.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\AjtMaquette.xaml">
<SubType></SubType>
</MauiXaml>
<MauiXaml Update="View\%28%24&quot;{nameof%28BlocModel%29}%3FNom={s}&quot;%29%3B.xaml">
<SubType></SubType>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<MauiImage Remove="Resources\Images\dotnet_bot.svg" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Images\dotnet_bot.svg" />
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.EntityFrameworkCore" />
<None Remove="Microsoft.EntityFrameworkCore.Tools" />
<None Remove="Microsoft.EntityFrameworkCore.Sqlite" />
<None Remove="sqlite-net-pcl" />
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
using System;
namespace CalculateurApp
{
public static class DataBase_constante
{
public const string DatabaseName = "calculDb.db3";
public const SQLite.SQLiteOpenFlags flags = SQLite.SQLiteOpenFlags.ReadWrite | SQLite.SQLiteOpenFlags.Create | SQLite.SQLiteOpenFlags.SharedCache;
public static string DatabasePath => Path.Combine(FileSystem.AppDataDirectory, DatabaseName);
}
}

@ -20,8 +20,10 @@ namespace CalculateurApp
// builder.Services.AddSingleton<UEPage1>();
// builder.Services.AddSingleton<UeViewModel>();
builder.Services.AddSingleton<Maquette>();
builder.Services.AddSingleton<BlockView>();
builder.Services.AddSingleton<MaquetteViewModel>();
builder.Services.AddSingleton<AjtMaquette>();
builder.Services.AddSingleton<PageAjoutMaquette>();
builder.Services.AddTransient<Start>();
builder.Services.AddTransient<BlocViewModel>();

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CalculateurApp.View.Maquette"
x:Class="CalculateurApp.View.BlockView"
xmlns:viewmodel="clr-namespace:CalculateurApp.ViewModel"
x:DataType="viewmodel:MaquetteViewModel"
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="Maquette">
Title="BlockView">
<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".75*,.25*"
@ -17,7 +17,7 @@
Text="{Binding blocModel.Nom }"
TextColor="Black"
/>
<Button x:Name="Afer" Text="Modifier" Grid.Row="1" Grid.Column="1" HorizontalOptions="End" VerticalOptions="End" WidthRequest="80"></Button>
<Button x:Name="Afer" Text="Modifier" Grid.Row="1" Grid.Column="1" HorizontalOptions="End" VerticalOptions="End" WidthRequest="80" Command="{Binding GetAllBlocCommand}"> </Button>
<Button
Command="{Binding AddCommand}"
Text="ajouter"

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

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CalculateurApp.View.AjtMaquette"
xmlns:viewmodel="clr-namespace:CalculateurApp.ViewModel"
x:DataType="viewmodel:PageAjoutMaquette"
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="Maquette">
<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".75*,.25*"
Padding="2"
RowSpacing="4"
ColumnSpacing="4">
<Entry Placeholder="Ajout de LA MAQUETTE"
Grid.Row="1" BackgroundColor="AliceBlue"
Text="{Binding NomMaquette }"
TextColor="Black"
/>
<Button
Command="{Binding AddCommand}"
Text="Ajouter"
Grid.Row="1"
Grid.Column="1"
HorizontalOptions="Start"
VerticalOptions="Center"
WidthRequest="85"
>
</Button>
<Button Command="{Binding AddCommand}"
Text="Modifier"
Grid.Row="1"
Grid.Column="2"
HorizontalOptions="End"
VerticalOptions="End"
BackgroundColor="AliceBlue"
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="Multiple" BackgroundColor="White">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:MaquetteModel }">
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Text="Delete"
BackgroundColor="Red"
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:PageAjoutMaquette}}, Path=DeleteCommand}"
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>
</SwipeView.RightItems>
<Grid Padding="0">
<Frame Grid.Row="1">
<Frame.GestureRecognizers >
<TapGestureRecognizer
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=GoBackCommand}"
CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Label Text="{Binding NomMaquette}"
FontSize="10" TextColor="Black"
/>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView >
</Grid>
</ContentPage>

@ -0,0 +1,13 @@
using CalculateurApp.ViewModel;
namespace CalculateurApp.View;
public partial class AjtMaquette : ContentPage
{
public AjtMaquette(PageAjoutMaquette vm)
{
InitializeComponent();
BindingContext = vm;
Routing.RegisterRoute(nameof(BlockView), typeof(BlockView));
}
}

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CalculateurApp.View.MatNote"
@ -18,6 +18,7 @@
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Entry
BackgroundColor="AliceBlue"
@ -31,45 +32,71 @@
Text="/"
HorizontalOptions="Center"
/>
<Entry
<Entry
WidthRequest="100"
Grid.Column="2"
Placeholder="SUR"
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
<Label Text=" MATIERE" Grid.Row="1" HorizontalOptions="Center" />
<Label Text=" MATIERE" Grid.Row="1" HorizontalOptions="Start" FontSize="Header"/>
<Entry
WidthRequest="130"
WidthRequest="100"
Grid.Row="2"
HorizontalOptions="Center"
HorizontalOptions="Start"
Placeholder="nom de la matiére"
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
<Label Text=" coef" Grid.Row="1" Grid.Column="2" HorizontalOptions="Center"/>
<Label Text=" coefficient" Grid.Row="1" Grid.Column="2" HorizontalOptions="Center" FontSize="Header"/>
<Entry
WidthRequest="150"
WidthRequest="100"
Grid.Row="2"
Grid.Column="2"
Placeholder="COEFFICIENT"
BackgroundColor="AliceBlue"
VerticalOptions="Start"
/>
/>
<Button Grid.Row="2" Text="Annuler" HorizontalOptions="Start" VerticalOptions="Start" Grid.Column="3" ></Button>
<Button Grid.Row="2" Text="Ajouter" HorizontalOptions="Center" VerticalOptions="Start" Grid.Column="4" WidthRequest="90"></Button>
<CollectionView Grid.ColumnSpan="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="5" ColumnSpacing="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Row="1"
Grid.Column="0"
Text="nom"
FontAttributes="None"
VerticalOptions="End"/>
<Label Grid.Column="3"
Grid.Row="1"
Text="coef"
TextColor="Blue"
FontAttributes="Bold" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Button Text="Annuler" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="110" Grid.Column="0" ></Button>
<Button Text="Ajouter" HorizontalOptions="Start" VerticalOptions="Center" Grid.Column="2" WidthRequest="110"></Button>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodel="clr-namespace:CalculateurApp.ViewModel"

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodel="clr-namespace:CalculateurApp.ViewModel"
@ -16,7 +16,7 @@
<Entry
Placeholder="entrer matiere"
Grid.Row="1"
Text="{Binding ma.Nommatiere}"
Text="y"
TextColor="Black"
BackgroundColor="AliceBlue"
WidthRequest="250"
@ -24,6 +24,8 @@
<!--<Label Text="{Binding }"></Label>-->
<!--<Button Text="go" Command="{Binding AddCommand}"></Button>-->
<!--<Entry
{Binding ma.Nommatiere}
Placeholder="coef"
WidthRequest="100"
Grid.Row="1"
@ -53,7 +55,7 @@
CommandParameter="{Binding .}"/>
</Frame.GestureRecognizers>
<Label Text="{Binding Nommatiere}"
<Label Text="Binding Nommatiere"
FontSize="10" TextColor="Black" />
</Frame>
</Grid>
@ -61,7 +63,8 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView Grid.Row="2" Grid.Column="0" ItemsSource="{Binding Items}" >
<CollectionView Grid.Row="2" Grid.Column="0" >
<!--ItemsSource="{Binding Items}"-->
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:Matiere }">
<SwipeView>
@ -81,7 +84,7 @@
CommandParameter="{Binding .}"/>
</Frame.GestureRecognizers>
<Label Text="{Binding Nommatiere}"
<Label Text="Binding Nommatiere"
FontSize="10" TextColor="Black" />
</Frame>
</Grid>

@ -7,6 +7,10 @@ public partial class UEPage1 : ContentPage
public UEPage1()
{
InitializeComponent();
BindingContext = new UeViewModel();
//BindingContext = new UeViewModel();
}
private void AddUEBloc(object sender, EventArgs e)
{
Navigation.PushAsync(new BlockView());
}
}

@ -5,28 +5,28 @@
x:DataType="viewmodel:BlocViewModel"
x:Class="CalculateurApp.View.EXE"
Title="Maquette">
<Grid RowDefinitions="100 ,Auto,*"
<!--<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".75*,.25*"
Padding="2"
RowSpacing="4"
ColumnSpacing="4">
<Entry Placeholder="Ajout de BLOC DANS LA MAQUETTE"
<Entry Placeholder="Ajout de LA MAQUETTE"
Grid.Row="1" BackgroundColor="AliceBlue"
Text="{Binding blocModel.Nom }"
TextColor="Black"
/>
<Button
--><!--<Button
Text="Modifier"
Text="AJOUTER"
Grid.Row="1"
Grid.Column="1"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="100"
>
<!--Command="{Binding AddUEBlocCommand}"-->
</Button>
--><!--Command="{Binding AddUEBlocCommand}"--><!--
</Button>-->
<!--<Label Text="Liste des blocs" Grid.Row="2" Grid.ColumnSpan="2" FontSize="Header" HorizontalOptions="Center" TextDecorations="Underline" TextColor="Black" FontAttributes="Bold, Italic" ></Label>
<CollectionView Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
@ -59,8 +59,8 @@
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView >-->
</Grid>
</CollectionView >--><!--
</Grid>-->
</ContentPage>

@ -10,14 +10,15 @@ using System.Threading.Tasks;
namespace CalculateurApp.ViewModel
{
[QueryProperty("Nom", "Nom")]
public partial class BlocViewModel:ObservableObject
public partial class BlocViewModel:ObservableObject,IQueryAttributable
{
[ObservableProperty]
string nom;
public BlocModel blocModel { get; set; }
public UE ue { get; set; }
public BlocViewModel()
{
Items = new ObservableCollection<UE>();
@ -50,12 +51,28 @@ namespace CalculateurApp.ViewModel
Items.Remove(bl);
}
}
[RelayCommand]
void GEtAllUE(UE bl)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
}
}
[RelayCommand]
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
var Maquette = query["maquette"]as MaquetteModel ;
blocModel.IDMaquetteFrk = Maquette.Id;
}
}

@ -1,6 +1,7 @@
using BSN;
using Bussness;
using CalculateurApp.View;
using CalculateurEF.Context;
using CalculateurMapping;
using ClassCalculateurMoyenne;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@ -8,6 +9,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
@ -15,30 +17,36 @@ namespace CalculateurApp.ViewModel
{
public partial class MaquetteViewModel:ObservableObject
{
// public Maquette maquette { get; set; }
public BlocModel blocModel { get; set; }
// public ReadOnlyObservableCollection<BlocModel>lst { get; set; }
public Manager manager;
public MaquetteViewModel()
{
Items = new ObservableCollection<BlocModel>();
//foreach (var BB in manager.GetAllBloc().Result)
// Items.Add(BB);
blocModel = new BlocModel();
}
[ObservableProperty]
ObservableCollection<BlocModel> items;
[ObservableProperty]
ObservableCollection<BlocModel> lstblc=new ObservableCollection<BlocModel>();
[ObservableProperty]
string nom;
[RelayCommand]
void Add()
{
Manager blocDbDataManager = new Manager(new BlocDbDataManager<CalculDbMaui>());
if (string.IsNullOrEmpty(blocModel.Nom))
return;
BlocModel u = new BlocModel(blocModel.Nom);
//u.Intitulé = ue.Intitulé;
BlocModel u = new BlocModel(blocModel.Nom);
Items.Add(u);
blocModel.Nom = string.Empty;
blocDbDataManager.AddBloc(blocModel);
blocModel.Nom = string.Empty;
}
[RelayCommand]
void Delete(BlocModel bl)
@ -49,6 +57,17 @@ namespace CalculateurApp.ViewModel
Items.Remove(bl);
}
}
[RelayCommand]
void AjoutUE(BlocModel bl)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
}
}
[RelayCommand]
@ -58,10 +77,27 @@ namespace CalculateurApp.ViewModel
}
[RelayCommand]
public void GetAllUE()
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
var Maquette = query["maquette"] as MaquetteModel;
blocModel.IDMaquetteFrk = Maquette.Id;
}
[RelayCommand]
public void GetAllBloc()
{
// var result=Manager
var result = manager.GetAllBloc();
foreach(var item in result.Result)
{
lstblc.Add(item);
}
}
}
}

@ -0,0 +1,91 @@
using System;
using System.Collections.ObjectModel;
using ClassCalculateurMoyenne;
using CalculateurMapping;
using Bussness;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CalculateurApp.View;
using System.Linq;
namespace CalculateurApp.ViewModel
{
public partial class PageAjoutMaquette : ObservableObject
{
public MaquetteModel maquette { get; set; }
public Manager manager;
public PageAjoutMaquette()
{
manager = new Manager(new MaquetteDbDataManager<CalculDbMaui>());
Items = new ObservableCollection<MaquetteModel>();
foreach(var mm in manager.GetAllMaquette().Result)
Items.Add( mm);
maquette = new MaquetteModel();
}
[ObservableProperty]
ObservableCollection<MaquetteModel> items;
public string NomMaquette
{
get => maquette.NomMaquette;
set => SetProperty(maquette.NomMaquette, value, maquette, (u, v) => u.setNomMaquete(v));
}
[RelayCommand]
async void Add()
{
Manager maquetteDbDataManager = new Manager(new MaquetteDbDataManager<CalculDbMaui>());
if (string.IsNullOrEmpty(NomMaquette))
return;
MaquetteModel u = maquette;
Items.Add(u);
await maquetteDbDataManager.AddMaquette(maquette);
//maquette.NomMaquette = string.Empty;
}
[RelayCommand]
async void Delete(MaquetteModel model)
{
if (Items.Contains(model))
{
Items.Remove(model);
await manager.Deletemqt(model);
var v = await manager.GetAllMaquette();
Console.WriteLine(v);
}
}
[RelayCommand]
async void GetAllMaquette()
{
Manager maquetteDbDataManager = new Manager(new MaquetteDbDataManager<CalculDbMaui>());
await maquetteDbDataManager.GetAllMaquette();
}
[RelayCommand]
async Task GoBack(string maquetteName)
{
var maquette = manager.GetMaquetteByName(maquetteName);
var parametre = new Dictionary<string, Object>
{
{"maquette",maquette }
};
await Shell.Current.GoToAsync($"{nameof(BlockView)}",parametre);
}
}
}

@ -1,5 +1,6 @@
using CalculateurEF.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
@ -19,7 +20,20 @@ namespace CalculateurEF.Context
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=calcul.db");
//optionsBuilder.UseSqlite("Data Source=calcul.db");
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite("Data Source=calcul.db");
}
}
public CalculContext()
{
}
public CalculContext(DbContextOptions<CalculContext> options) : base(options)
{
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,10 +9,25 @@ namespace CalculateurEF.Entities
{
public class BlocEntity
{
#region Propriétés
public List<UEentity> ue;
#region Propriétés
public int Id { get; set; }
public string Nom;
public string Nom { get; set; }
public ICollection<UEentity> UeEntityId { get; set; } = new List<UEentity>();
public int IDMaquetteFrk
{
get; set;
}
[ForeignKey("IDMaquetteFrk")]
public MaquetteEntity MaquetteEntity
{
get; set;
}
//public ICollection<UEentity> ue { get; set; }

@ -13,7 +13,9 @@ namespace CalculateurEF.Entities
#region Propriétés
public int Id { get; set; }
public string NomMaquette { get; set; }
public ICollection<BlocEntity> Bloc { get; set; }
public ICollection<BlocEntity> Bloc { get; set; }= new List<BlocEntity>();
// public ICollection<UEentity> UeEntityId { get; set; } = new List<UEentity>();
#endregion
#region Constructeurs
public MaquetteEntity()

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -12,6 +13,15 @@ namespace CalculateurEF.Entities
public long id { get; set; }
public int Note { get; set; }
public int Coef { get; set; }
public long IDUEForeignKey
{
get; set;
}
[ForeignKey("IDUEForeignKey")]
public UEentity UEentity
{
get; set;
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
@ -10,12 +11,20 @@ namespace CalculateurEF.Entities
public class UEentity
{
public long Id { get; set; }
public int Coefficient { get; set; }
public string intitulé { get; set; }
public ICollection<MatiereEntity> mat { get; set; }
public List<MatiereEntity> matiere;
public ICollection<MatiereEntity> mat { get; set; }=
new List<MatiereEntity> ();
public int IDForeignKey
{
get; set;
}
[ForeignKey("IDForeignKey")]
public BlocEntity BlocEntity
{
get; set;
}
public UEentity()
{

@ -1,5 +1,4 @@
// <auto-generated />
using System;
using CalculateurEF.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -11,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CalculateurEF.Migrations
{
[DbContext(typeof(CalculContext))]
[Migration("20221203193812_TestCalc")]
partial class TestCalc
[Migration("20221211125750_Migrations")]
partial class Migrations
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -26,7 +25,7 @@ namespace CalculateurEF.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("MaquetteEntityId")
b.Property<int>("IDMaquetteFrk")
.HasColumnType("INTEGER");
b.Property<string>("Nom")
@ -35,7 +34,7 @@ namespace CalculateurEF.Migrations
b.HasKey("Id");
b.HasIndex("MaquetteEntityId");
b.HasIndex("IDMaquetteFrk");
b.ToTable("Bloc");
});
@ -64,6 +63,9 @@ namespace CalculateurEF.Migrations
b.Property<int>("Coef")
.HasColumnType("INTEGER");
b.Property<long>("IDUEForeignKey")
.HasColumnType("INTEGER");
b.Property<string>("Nommatiere")
.IsRequired()
.HasColumnType("TEXT");
@ -71,12 +73,9 @@ namespace CalculateurEF.Migrations
b.Property<int>("Note")
.HasColumnType("INTEGER");
b.Property<long?>("UEentityId")
.HasColumnType("INTEGER");
b.HasKey("id");
b.HasIndex("UEentityId");
b.HasIndex("IDUEForeignKey");
b.ToTable("matier");
});
@ -90,27 +89,56 @@ namespace CalculateurEF.Migrations
b.Property<int>("Coefficient")
.HasColumnType("INTEGER");
b.Property<int>("IDForeignKey")
.HasColumnType("INTEGER");
b.Property<string>("intitulé")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IDForeignKey");
b.ToTable("Ue");
});
modelBuilder.Entity("CalculateurEF.Entities.BlocEntity", b =>
{
b.HasOne("CalculateurEF.Entities.MaquetteEntity", null)
b.HasOne("CalculateurEF.Entities.MaquetteEntity", "MaquetteEntity")
.WithMany("Bloc")
.HasForeignKey("MaquetteEntityId");
.HasForeignKey("IDMaquetteFrk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MaquetteEntity");
});
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
{
b.HasOne("CalculateurEF.Entities.UEentity", null)
b.HasOne("CalculateurEF.Entities.UEentity", "UEentity")
.WithMany("mat")
.HasForeignKey("UEentityId");
.HasForeignKey("IDUEForeignKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UEentity");
});
modelBuilder.Entity("CalculateurEF.Entities.UEentity", b =>
{
b.HasOne("CalculateurEF.Entities.BlocEntity", "BlocEntity")
.WithMany("UeEntityId")
.HasForeignKey("IDForeignKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BlocEntity");
});
modelBuilder.Entity("CalculateurEF.Entities.BlocEntity", b =>
{
b.Navigation("UeEntityId");
});
modelBuilder.Entity("CalculateurEF.Entities.MaquetteEntity", b =>

@ -5,7 +5,7 @@
namespace CalculateurEF.Migrations
{
/// <inheritdoc />
public partial class TestCalc : Migration
public partial class Migrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -24,36 +24,44 @@ namespace CalculateurEF.Migrations
});
migrationBuilder.CreateTable(
name: "Ue",
name: "Bloc",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Coefficient = table.Column<int>(type: "INTEGER", nullable: false),
intitulé = table.Column<string>(type: "TEXT", nullable: false)
Nom = table.Column<string>(type: "TEXT", nullable: false),
IDMaquetteFrk = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Ue", x => x.Id);
table.PrimaryKey("PK_Bloc", x => x.Id);
table.ForeignKey(
name: "FK_Bloc_Maquettes_IDMaquetteFrk",
column: x => x.IDMaquetteFrk,
principalTable: "Maquettes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Bloc",
name: "Ue",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nom = table.Column<string>(type: "TEXT", nullable: false),
MaquetteEntityId = table.Column<int>(type: "INTEGER", nullable: true)
Coefficient = table.Column<int>(type: "INTEGER", nullable: false),
intitulé = table.Column<string>(type: "TEXT", nullable: false),
IDForeignKey = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bloc", x => x.Id);
table.PrimaryKey("PK_Ue", x => x.Id);
table.ForeignKey(
name: "FK_Bloc_Maquettes_MaquetteEntityId",
column: x => x.MaquetteEntityId,
principalTable: "Maquettes",
principalColumn: "Id");
name: "FK_Ue_Bloc_IDForeignKey",
column: x => x.IDForeignKey,
principalTable: "Bloc",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -65,43 +73,49 @@ namespace CalculateurEF.Migrations
Nommatiere = table.Column<string>(type: "TEXT", nullable: false),
Note = table.Column<int>(type: "INTEGER", nullable: false),
Coef = table.Column<int>(type: "INTEGER", nullable: false),
UEentityId = table.Column<long>(type: "INTEGER", nullable: true)
IDUEForeignKey = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_matier", x => x.id);
table.ForeignKey(
name: "FK_matier_Ue_UEentityId",
column: x => x.UEentityId,
name: "FK_matier_Ue_IDUEForeignKey",
column: x => x.IDUEForeignKey,
principalTable: "Ue",
principalColumn: "Id");
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Bloc_MaquetteEntityId",
name: "IX_Bloc_IDMaquetteFrk",
table: "Bloc",
column: "MaquetteEntityId");
column: "IDMaquetteFrk");
migrationBuilder.CreateIndex(
name: "IX_matier_UEentityId",
name: "IX_matier_IDUEForeignKey",
table: "matier",
column: "UEentityId");
column: "IDUEForeignKey");
migrationBuilder.CreateIndex(
name: "IX_Ue_IDForeignKey",
table: "Ue",
column: "IDForeignKey");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Bloc");
name: "matier");
migrationBuilder.DropTable(
name: "matier");
name: "Ue");
migrationBuilder.DropTable(
name: "Maquettes");
name: "Bloc");
migrationBuilder.DropTable(
name: "Ue");
name: "Maquettes");
}
}
}

@ -1,5 +1,4 @@
// <auto-generated />
using System;
using CalculateurEF.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -23,7 +22,7 @@ namespace CalculateurEF.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("MaquetteEntityId")
b.Property<int>("IDMaquetteFrk")
.HasColumnType("INTEGER");
b.Property<string>("Nom")
@ -32,7 +31,7 @@ namespace CalculateurEF.Migrations
b.HasKey("Id");
b.HasIndex("MaquetteEntityId");
b.HasIndex("IDMaquetteFrk");
b.ToTable("Bloc");
});
@ -61,6 +60,9 @@ namespace CalculateurEF.Migrations
b.Property<int>("Coef")
.HasColumnType("INTEGER");
b.Property<long>("IDUEForeignKey")
.HasColumnType("INTEGER");
b.Property<string>("Nommatiere")
.IsRequired()
.HasColumnType("TEXT");
@ -68,12 +70,9 @@ namespace CalculateurEF.Migrations
b.Property<int>("Note")
.HasColumnType("INTEGER");
b.Property<long?>("UEentityId")
.HasColumnType("INTEGER");
b.HasKey("id");
b.HasIndex("UEentityId");
b.HasIndex("IDUEForeignKey");
b.ToTable("matier");
});
@ -87,27 +86,56 @@ namespace CalculateurEF.Migrations
b.Property<int>("Coefficient")
.HasColumnType("INTEGER");
b.Property<int>("IDForeignKey")
.HasColumnType("INTEGER");
b.Property<string>("intitulé")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IDForeignKey");
b.ToTable("Ue");
});
modelBuilder.Entity("CalculateurEF.Entities.BlocEntity", b =>
{
b.HasOne("CalculateurEF.Entities.MaquetteEntity", null)
b.HasOne("CalculateurEF.Entities.MaquetteEntity", "MaquetteEntity")
.WithMany("Bloc")
.HasForeignKey("MaquetteEntityId");
.HasForeignKey("IDMaquetteFrk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MaquetteEntity");
});
modelBuilder.Entity("CalculateurEF.Entities.MatiereEntity", b =>
{
b.HasOne("CalculateurEF.Entities.UEentity", null)
b.HasOne("CalculateurEF.Entities.UEentity", "UEentity")
.WithMany("mat")
.HasForeignKey("UEentityId");
.HasForeignKey("IDUEForeignKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UEentity");
});
modelBuilder.Entity("CalculateurEF.Entities.UEentity", b =>
{
b.HasOne("CalculateurEF.Entities.BlocEntity", "BlocEntity")
.WithMany("UeEntityId")
.HasForeignKey("IDForeignKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BlocEntity");
});
modelBuilder.Entity("CalculateurEF.Entities.BlocEntity", b =>
{
b.Navigation("UeEntityId");
});
modelBuilder.Entity("CalculateurEF.Entities.MaquetteEntity", b =>

@ -1,4 +1,4 @@
using BSN;
using Bussness;
using CalculateurEF.Context;
using CalculateurEF.Entities;
using ClassCalculateurMoyenne;
@ -11,84 +11,125 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class BlocDbDataManager : IDataManager<BlocModel>
{
public async Task<bool> Add(BlocModel data)
public class BlocDbDataManager<TContext>: IDataManager<BlocModel> where TContext :CalculContext,new()
{//ajout de bloc
public async Task<bool> Add(BlocModel blc)
{
bool resultat = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
BlocEntity entity = new BlocEntity
{
Nom = data.Getnom(),
};
for (int i = 0; i < data.ue.Count; i++)
{
UEentity uEentity = new UEentity
{
intitulé = data.ue[i].Intitulé
};
Nom = blc.GetNom(),
IDMaquetteFrk=blc.IDMaquetteFrk
};
context.Bloc.Add(entity);
await context.SaveChangesAsync();
context.SaveChanges();
resultat = true;
}
return resultat;
}
}
return resultat;
}//delete
public async Task<bool> Delete(BlocModel bloc)
{
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
BlocEntity entity = context.Bloc.Find(bloc.Nom);
BlocEntity entity = context.Bloc.Find(bloc.Id);
context.Bloc.Remove(entity);
result = await context.SaveChangesAsync() > 0;
}
return true;
}
public async Task<IEnumerable<BlocModel>> GetAll()
public async Task<bool> DeleteById(int id)
{
using (var context = new CalculContext())
bool result = false;
using (var context = new TContext())
{
return await context.Bloc.Select(e => new BlocModel
BlocEntity entity = context.Bloc.Find(id);
context.Bloc.Remove(entity);
result = await context.SaveChangesAsync() > 0;
}
return true;
}
public async Task<List<BlocModel>> GetAll()
{ //getAll
using (var context = new TContext())
{
var temp= await context.Bloc.Select(e => new BlocModel
(
e.Nom,
e.Id,
e.ue.Select(j => new UE(j.intitulé)).ToArray()
e.Id, new UE[0]
//e.ue.Select(j => new UE(j.intitulé)).ToArray()
)).ToListAsync();
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)
{
using (var context = new CalculContext())
using (var context = new TContext())
{
return await context.Bloc.Where(e => e.Nom == name).Select(e => new BlocModel
(
e.Nom,
e.ue.Select(j => new UE(j.intitulé)).ToArray()
e.UeEntityId.Select(j => new UE(j.intitulé)).ToArray()
)).FirstOrDefaultAsync();
}
}
public async Task<bool> Update(BlocModel data)
{
{//update
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
BlocEntity entity = context.Bloc.Find(data.Id);
entity.Nom = data.Nom ;
entity.ue = data.ue.Select(j => new UEentity
entity.UeEntityId = data.ue.Select(j => new UEentity
{
intitulé = j.Intitulé,
}).ToList();
result = await context.SaveChangesAsync() > 0;
bool v = await context.SaveChangesAsync() > 0;
result = v;
}
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;
}
}
}
}

@ -1,4 +1,4 @@
using BSN;
using Bussness;
using CalculateurEF.Context;
using CalculateurEF.Entities;
using ClassCalculateurMoyenne;
@ -11,42 +11,54 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class MaquetteDbDataManager : IDataManager<MaquetteModel>
public class MaquetteDbDataManager<TContext> : IDataManager<MaquetteModel> where TContext : CalculContext, new()
{
public async Task<bool> Add(MaquetteModel mqt)
public MaquetteDbDataManager()
{
using (var context = new TContext())
{
context.Database.EnsureCreated();
}
}
public async Task<bool> Add(MaquetteModel mqt)
{ //Add mqt
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
//context.Database.EnsureCreated();
MaquetteEntity entity = new MaquetteEntity
{
NomMaquette = mqt.GetNomMaquette(),
NomMaquette = mqt.NomMaquette,
};
for (int i = 0; i < mqt.BLOCS.Count; i++)
{
BlocEntity blocentitie = new BlocEntity
{
Nom = mqt.BLOCS[i].Nom
};
context.Maquettes.Add(entity);
await context.SaveChangesAsync();
result = true;
}
context.Maquettes.Add(entity);
context.SaveChanges();
return result;
}
}
//delete maquette
public async Task<bool> Delete(MaquetteModel maquette)
{
bool result = false;
using (var context = new TContext())
{
MaquetteEntity entity = context.Maquettes.Find(maquette.Id);
context.Maquettes.Remove(entity);
result = await context.SaveChangesAsync() > 0;
}
return result;
}
public async Task<bool> Delete(MaquetteModel maquette)
//delete maquette
public async Task<bool> DeleteById(MaquetteModel maquette)
{
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
MaquetteEntity entity = context.Maquettes.Find(maquette.GetNomMaquette());
MaquetteEntity entity = context.Maquettes.Find(maquette.Id);
context.Maquettes.Remove(entity);
result = await context.SaveChangesAsync() > 0;
@ -72,21 +84,12 @@ namespace CalculateurMapping
// }
// return null;
// }
public async Task<IEnumerable<MaquetteModel>> GetAll()
{
using (var context = new CalculContext())
{
List<MaquetteModel> maquettes = new List<MaquetteModel>();
foreach (var item in await context.Maquettes.ToListAsync())
maquettes.Add(new MaquetteModel(item.Id, item.NomMaquette));
return maquettes;
}
}
public async Task<MaquetteModel> GetDataWithName(string name)
{
using (var context = new CalculContext())
using (var context = new TContext())
{
MaquetteModel _mqt = null;
@ -95,26 +98,14 @@ namespace CalculateurMapping
return _mqt;
}
}
//using (var context = new CalculContext())
//{
// return await context.Maquettes.Where(e => e.NomMaquette == name).Select(e => new MaquetteModel
// (
//e.Id,
//e.NomMaquette,
//e.Bloc.Select(u => u.ue).ToList(),
//e.Bloc.Select(j => new BlocModel(j.Nom)).ToArray()
// )).FirstOrDefaultAsync();
//}
public async Task<bool> Update(MaquetteModel data)
{
{//update mqt
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
MaquetteEntity entity = context.Maquettes.Find(data.Id);
entity.NomMaquette = data.GetNomMaquette();
entity.NomMaquette = data.NomMaquette;
entity.Bloc = data.BLOCS.Select(j => new BlocEntity
{
Nom=j.Nom,
@ -123,5 +114,24 @@ namespace CalculateurMapping
}
return result;
}
//getAll mqt
public async Task<List<MaquetteModel>> GetAll()
{
using (var context = new TContext())
{
List<MaquetteModel> maquettes = new List<MaquetteModel>();
foreach (var item in await context.Maquettes.ToListAsync())
{
// Console.WriteLine(item);
maquettes.Add(new MaquetteModel(item.Id, item.NomMaquette));
}
return maquettes;
}
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}
}

@ -1,4 +1,4 @@
using BSN;
using Bussness;
using CalculateurEF.Context;
using CalculateurEF.Entities;
using ClassCalculateurMoyenne;
@ -31,6 +31,11 @@ namespace CalculateurMapping
}
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
public async Task<bool> Delete(Matiere mat)
{
bool result = false;
@ -43,7 +48,7 @@ namespace CalculateurMapping
return result;
}
public async Task<IEnumerable<Matiere>> GetAll()
public async Task<List<Matiere>> GetAll()
{
using (var context = new CalculContext())
{

@ -1,4 +1,4 @@
using BSN;
using Bussness;
using CalculateurEF.Context;
using CalculateurEF.Entities;
using ClassCalculateurMoyenne;
@ -38,6 +38,11 @@ namespace CalculateurMapping
}
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
public async Task<bool> Delete(UE data)
{
bool result = false;
@ -51,7 +56,7 @@ namespace CalculateurMapping
return true;
}
public async Task<IEnumerable<UE>> GetAll()
public async Task<List<UE>> GetAll()
{
using (var context = new CalculContext())
{
@ -60,7 +65,7 @@ namespace CalculateurMapping
e.Id,
e.Coefficient,
e.intitulé,
e.matiere.Select(j => new Matiere(j.Nommatiere)).ToArray()
e.mat.Select(j => new Matiere(j.Nommatiere)).ToArray()
)).ToListAsync();
}
}
@ -77,7 +82,7 @@ namespace CalculateurMapping
{
UEentity entity = context.Ue.Find(data.Id);
entity.intitulé = data.Intitulé;
entity.matiere = data.Matieres.Select(j => new MatiereEntity
entity.mat = data.Matieres.Select(j => new MatiereEntity
{
Nommatiere = j.Nommatiere,
}).ToList();

@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculateurMapping", "Calcu
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bussness", "BSN\Bussness.csproj", "{EE834623-6D68-4016-94B9-FF3AC58C0E15}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "testpourEf", "testpourEf\testpourEf.csproj", "{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testpourEf", "testpourEf\testpourEf.csproj", "{48B8C47A-AC35-473C-A9A9-CE9C8D5F6344}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -1,4 +1,5 @@
using ClassCalculateurMoyenne;
using Bussness;
using ClassCalculateurMoyenne;
//using ClassCalculateurMoyenne.Modele;
using System;
using System.Collections.Generic;
@ -9,7 +10,7 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub
{
public class StubBloc
public class StubBloc: IDataManager<BlocModel>
{
private List<BlocModel> listb = new List<BlocModel>();
public List<UE> ue = new List<UE>();
@ -23,19 +24,9 @@ namespace StubCalculateur.Stub
}
return false;
}
public bool Delete(BlocModel data)
{
if (data != null)
{
listb.Remove(data);
return true;
}
return false;
}
public async Task<IEnumerable<BlocModel>> GetAll()
{
return listb;
}
public async Task<bool> Update(BlocModel data)
{
if (data != null)
@ -46,7 +37,18 @@ namespace StubCalculateur.Stub
}
return false;
}
public IEnumerable<BlocModel> GetAllUE(int n = 10)
public async Task<IEnumerable<BlocModel>> GetAllUEdb(int n = 10)
{
for (int j = 0; j < n; j++)
{
ue.Add(new UE(""));
}
listb.Add(new BlocModel("ue"));
ue.Clear();
return listb;
}
public async Task <IEnumerable<BlocModel>> GetAllBloc(int n = 10)
{
for (int i = 0; i < n; i++)
{
@ -60,10 +62,30 @@ namespace StubCalculateur.Stub
return listb;
}
public Task<bool> Delete(BlocModel data)
{
if (data != null)
{
listb.Remove(data);
return Task.FromResult( true);
}
return Task.FromResult(false);
}
public Task<BlocModel> GetDataWithName(string name)
{
throw new NotImplementedException();
}
public async Task<List<BlocModel>> GetAll()
{
return listb;
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}

@ -1,42 +1,20 @@
using ClassCalculateurMoyenne;
using ClassCalculateurMoyenne;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bussness;
namespace StubCalculateur.Stub
{
public class StubMaquette
public class StubMaquette: IDataManager<MaquetteModel>
{
private List<BlocModel> listb = new List<BlocModel>();
public List<UE> ues = new List<UE>();
private List<MaquetteModel> lstmqt = new List<MaquetteModel>();
public bool Delete(MaquetteModel data)
{
if (data != null)
{
lstmqt.Remove(data);
return true;
}
return false;
}
public bool Add(MaquetteModel data)
{
if(data != null)
{
lstmqt.Add(data);
return true;
}
return false;
}
public async Task<IEnumerable<MaquetteModel>> GetAll()
{
return lstmqt;
}
public async Task<IEnumerable<MaquetteModel>> GetAllMaquette(int n = 10)
{
for (int i = 0; i < n; i++)
@ -64,7 +42,7 @@ namespace StubCalculateur.Stub
}
for(int v = 0; v < 10; v++)
{
listb.Add(new BlocModel(""));
listb.Add(new BlocModel("ghh"));
}
lstmqt.Add(new MaquetteModel(ues,listb));
ues.Clear();
@ -72,9 +50,40 @@ namespace StubCalculateur.Stub
return lstmqt;
}
public Task<bool> Add(MaquetteModel data)
{
if (data != null)
{
lstmqt.Add(data);
return Task.FromResult(true);
}
return Task.FromResult(false);
}
public Task<bool> Delete (MaquetteModel data)
{
if (data != null)
{
lstmqt.Remove(data);
return Task.FromResult( true);
}
return Task.FromResult(false);
}
public Task<MaquetteModel> GetDataWithName(string name)
{
throw new NotImplementedException();
}
public async Task<List<MaquetteModel>> GetAll()
{
return lstmqt;
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}
}

@ -1,4 +1,5 @@
using ClassCalculateurMoyenne;
using Bussness;
using ClassCalculateurMoyenne;
using System;
using System.Collections;
using System.Collections.Generic;
@ -8,7 +9,7 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub
{
public class StubMatiere
public class StubMatiere: IDataManager<Matiere>
{
private List<Matiere> listMatieres = new List<Matiere>();
@ -31,12 +32,22 @@ namespace StubCalculateur.Stub
}
return false;
}
public async Task<IEnumerable<Matiere>> GetAll()
public Task<bool> Delete(Matiere data)
{
return listMatieres;
throw new NotImplementedException();
}
public bool update(Matiere data)
public Task<Matiere> GetDataWithName(string name)
{
throw new NotImplementedException();
}
public async Task<bool> Update(Matiere data)
{
if (data != null)
{
@ -47,5 +58,14 @@ namespace StubCalculateur.Stub
return false;
}
public async Task<List<Matiere>> GetAll()
{
return listMatieres;
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}
}

@ -1,4 +1,5 @@
using ClassCalculateurMoyenne;
using Bussness;
using ClassCalculateurMoyenne;
using System;
using System.Collections;
using System.Collections.Generic;
@ -8,10 +9,11 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub
{
public class stubUE
public class stubUE : IDataManager<UE>
{
private List<UE> listUE = new List<UE>();
private List<Matiere> mat = new List<Matiere>();
public async Task<bool> Add(UE data)
{
if (data != null)
@ -21,10 +23,6 @@ namespace StubCalculateur.Stub
}
return false;
}
public async Task<bool> Delete(UE data)
{
if (data != null)
@ -42,11 +40,7 @@ namespace StubCalculateur.Stub
}
return listUE;
}
public async Task<IEnumerable<UE>> GetAll()
{
return listUE;
}
public async Task<bool> Update(UE data)
{
if (data != null)
@ -71,10 +65,21 @@ namespace StubCalculateur.Stub
mat.Clear();
}
return listUE;
}
public Task<UE> GetDataWithName(string name)
{
throw new NotImplementedException();
}
public async Task<List<UE>> GetAll()
{
return listUE;
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}
}

@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\ClassCalculateurMoyenne\ClassCalculateurMoyenne.csproj" />
<ProjectReference Include="..\BSN\Bussness.csproj" />
</ItemGroup>
</Project>

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -12,47 +13,83 @@ namespace ClassCalculateurMoyenne
{
[ObservableProperty]
private string nom;
public long Id;
public int IDMaquetteFrk { get; set; }
public string GetNom()
{
return nom;
}
public int Id
{
get;
private set;
}
public void setNom(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Le Nom est obligatoire");
}
nom = value;
}
[ObservableProperty]
private UE[] uEs;
public ReadOnlyCollection<UE> ue { get; private set; }
public ReadOnlyCollection<UE> ue { get; private set; }//= new ReadOnlyCollection<UE>(new List<UE>());
private readonly List<UE> ues = new List<UE>();
private readonly List<UE> ues = new List<UE>();
public BlocModel(string nombloc)
{
nom = nombloc;
setNom(nombloc);
}
public BlocModel(string nombloc,long id, List<UE> Ux)
public BlocModel(string nombloc,int id, List<UE> Ux)
{
Id = id;
nom = nombloc;
ue = new ReadOnlyCollection<UE>(Ux);
ues.AddRange(Ux);
ue = new ReadOnlyCollection<UE>(ues);
//Ajouterue(Ux);
}
public BlocModel( List<UE> Ux)
{
ue = new ReadOnlyCollection<UE>(Ux);
}
public BlocModel(string nombloc, object value)
{
nom = nombloc;
}
public BlocModel(string nombloc, int id, UE[] uEs) : this(nombloc)
public BlocModel(string nombloc, int id, UE[] uEs)
{
nom = nombloc;
Id = id;
this.uEs = uEs;
}
//public int ueForeignKey
//{
// get; set;
//}
//[ForeignKey("ueForeignKey")]
//public UE UE
//{
// get; set;
//}
//public BlocModel(string v)
//{
//}
public BlocModel()
{
}
public string Getnom()
{
return Getnom();
}
}
private IEnumerable<UE> Ajouterue(params UE[] ues)
{
@ -61,17 +98,6 @@ namespace ClassCalculateurMoyenne
return result;
}
//public override string ToString()
//{
// return $"{ues}";
//}
//public IEnumerable<UE> Ajouterue(params UE[] ues)
//{
// List<UE> result = new();
// result.AddRange(ues.Where(a => Ajouterue(a)));
// return result;
//}
public bool Ajouterue(UE uu)
{
if (!IsExist(uu))
@ -97,7 +123,7 @@ namespace ClassCalculateurMoyenne
}
public bool Equals(BlocModel other)
{
return Nom. Equals(other.Nom);
return nom.Equals(other.GetNom());
}
public override bool Equals(object obj)
@ -109,7 +135,7 @@ namespace ClassCalculateurMoyenne
}
public override int GetHashCode()
{
return Nom.GetHashCode();
return nom.GetHashCode();
}
}
}

@ -10,55 +10,77 @@ namespace ClassCalculateurMoyenne
{
public class MaquetteModel:IEquatable<MaquetteModel>
{
public int Id;
public ReadOnlyCollection<UE> UES { get; set; }
public int Id
{
get;
set;
}
private readonly List<UE> ues = new List<UE>();
private string nomMaquette;
public ReadOnlyCollection<BlocModel> BLOCS { get; private set; }
private readonly List<BlocModel> blocs = new List<BlocModel>();
public string NomMaquette
{
get { return nomMaquette; }
private set
{
if (string.IsNullOrWhiteSpace(value))
public string NomMaquette;
public string GetNomMaquette()
{
return GetNomMaquette();
}
private void SetNomMaquette(string value)
{
if (string.IsNullOrWhiteSpace(GetNomMaquette()))
{
throw new ArgumentException("Le Nom de la maquette est obligatoire");
}
{
throw new ArgumentException("Le Nom de la maquette est obligatoire");
nomMaquette = value;
}
}
//public string GetNomMaquette()
//{
// return NomMaquette;
//}
//private void SetNomMaquette(string value)
//{
// if (string.IsNullOrWhiteSpace(value))
// {
// throw new ArgumentException("Le Nom de la maquette est obligatoire");
// }
// NomMaquette = value;
//}
public ReadOnlyCollection<UE> UES { get; private set; }
private readonly List<UE> ues = new List<UE>();
public ReadOnlyCollection<BlocModel> BLOCS { get; private set; }
private readonly List<BlocModel> blocs = new List<BlocModel>();
public MaquetteModel(int id, string nomMaquette, List<UE> u, List<BlocModel> blc)
{
Id = id;
NomMaquette = nomMaquette;
UES = u.AsReadOnly();
BLOCS = blc.AsReadOnly();
BLOCS = new ReadOnlyCollection<BlocModel>(blocs);
blocs.AddRange(blc);
}
public MaquetteModel(List<UE> u, List<BlocModel> blc)
public MaquetteModel(List<UE> u, List<BlocModel> blocs)
{
UES = u.AsReadOnly();
BLOCS = blc.AsReadOnly();
//la
BLOCS = new ReadOnlyCollection<BlocModel>(blocs);
}
public MaquetteModel(long id,string nomMaquette)
public MaquetteModel(int id,string nomMaquette)
{
Id = Id;
SetNomMaquette(nomMaquette);
Id = id;
setNomMaquete(nomMaquette);
}
public MaquetteModel( string nomMaquette)
{
SetNomMaquette(nomMaquette);
setNomMaquete(nomMaquette);
}
@ -80,10 +102,8 @@ namespace ClassCalculateurMoyenne
else
{
return false;
}
}
}
}
public bool ajouteBloc(BlocModel b)
{
if (IsExiste(b))
@ -118,7 +138,7 @@ namespace ClassCalculateurMoyenne
public bool Equals(MaquetteModel other)
{
return NomMaquette. Equals(other.GetNomMaquette());
return NomMaquette. Equals(other.NomMaquette);
}
public override bool Equals(object obj)
{
@ -131,17 +151,19 @@ namespace ClassCalculateurMoyenne
public MaquetteModel(string nomMaquette, int id)
{
SetNomMaquette(nomMaquette);
setNomMaquete(nomMaquette);
Id = id;
}
public void setNomMaquete(string nom)
public MaquetteModel()
{
SetNomMaquette(nom);
}
//pour faire les tests updt stub
public void setNomMaquete(string value)
{
NomMaquette = value;
}
}
}

@ -11,12 +11,12 @@ namespace ClassCalculateurMoyenne
{
public long Id { get; set; }
public string Nommatiere { get; set; }
public int Note { get; set; }
public int Coef { get; set; }
public string Nommatiere;
public int Note { get; private set; }
public int Coef { get; private set; }
public string GetNommatiere()
{
return GetNommatiere();
return Nommatiere;
}
private void SetNomMaquette(string value)

@ -10,13 +10,27 @@ namespace ClassCalculateurMoyenne
[ObservableProperty]
private int coefficient;
[ObservableProperty]
private string intitulé;
public int IDForeignKey { get; set; }
public string GetIntitulé()
{
return GetIntitulé();
return intitulé;
}
public void setIntitulé(string value)
{
if(string.IsNullOrEmpty(value))
{
throw new ArgumentException("INTITULÉ est obligatoire");
}
public UE ( long id, int coefficient, string intitulé,params Matiere[] matieres)
intitulé = value;
}
public UE ( long id, int coefficient, string intitulé,params Matiere[] matieres)
{
Id = id;
Coefficient = coefficient;
@ -24,20 +38,17 @@ namespace ClassCalculateurMoyenne
Matieres = new ReadOnlyCollection<Matiere>(matieres);
}
public void setIntitulé(string intitulé)
{
Intitulé = intitulé;
}
public UE( List<Matiere> _matieres, int coefficient)
public UE( List<Matiere> matieres, int coefficient)
{
Matieres = new ReadOnlyCollection<Matiere>(_matieres);
Matieres = new ReadOnlyCollection<Matiere>(matieres);
Coefficient = coefficient;
}
public UE(string intitulé)
{
this.intitulé = intitulé;
setIntitulé( intitulé);
}
public UE() { }

@ -8,8 +8,10 @@ namespace ClassCalculateurMoyenne
{
public class Utilisateur
{
public int id { get; set; }
public string Prenom { get; set; }
public int id { get;private set; }
public string Prenom { get;private set; }
}
}

@ -1,14 +1,56 @@
// See https://aka.ms/new-console-template for more information
using CalculateurEF.Context;
using CalculateurEF.Entities;
using Bussness;
using CalculateurMapping;
using ClassCalculateurMoyenne;
Console.WriteLine("Hello, World!");
namespace testpourEF
{ class Program
{
}
}
public class Program
{
private static async Task Main(string[] args)
{
Console.WriteLine("Hello, World!");
Manager blocDbDataManager = new Manager(new BlocDbDataManager<CalculContext>());
// Manager maquetteDbDataManager = new Manager(new MaquetteDbDataManager());
//Ajout de maquette
//MaquetteModel maquette = new MaquetteModel();
//maquette.NomMaquette = "M1";
//await maquetteDbDataManager.AddMaquette(maquette);
//AJOUT DE BLOC
//BlocModel bloc = new BlocModel();
//bloc.Nom = "Arafa";
//bloc.IDMaquetteFrk = 1;
//await blocDbDataManager.AddBloc(bloc);
//Modification
BlocModel bloc = new BlocModel();
var result = await blocDbDataManager.GetAllBloc();
result.First().Nom = "Elaphi";
await blocDbDataManager.UpdateBloc(result.First());
//suppresion de bloc
//BlocDbDataManager blocDbDataManager = new BlocDbDataManager();
// BlocModel bloc = new BlocModel();
// var result = await blocDbDataManager.GetAllBloc();
// await blocDbDataManager.DeleteById(1);
//ajout de ue dans bloc
//BlocDbDataManager blocDbDataManager1 = new BlocDbDataManager();
//BlocModel bloc = new BlocModel();
//UE uE = new UE();
//uE.Intitulé = "f";
//uE.IDForeignKey = 1;
//await blocDbDataManager.AddUEBloc(bloc);
}
}

@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)/../CalculateurEF/</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>

@ -0,0 +1,64 @@
using System;
using StubCalculateur.Stub;
using ClassCalculateurMoyenne;
using Bussness;
using Xunit;
namespace TestCalculateurMoyanne.LesTests
{
public class TestManager
{
[Fact]
public void TestAddMaquette()
{
MaquetteModel maquette = new MaquetteModel("B1");
Manager manager = new Manager(new StubMaquette());
manager.AddMaquette(maquette);
Assert.Single(manager.MaquetteDbDataManager.GetAll().Result);
}
[Fact]
public void TestAddBloc()
{
BlocModel bloc = new BlocModel("B1");
Manager manager = new Manager(new StubBloc());
manager.AddBloc (bloc);
Assert.Single(manager.BlocDbDataManager.GetAll().Result);
}
[Fact]
public void TestGetUEBloc()
{
BlocModel bloc = new BlocModel("B1");
Manager manager = new Manager(new StubBloc());
manager.AddBloc(bloc);
}
[Fact]
public void TestDELETEBloc()
{
BlocModel bloc = new BlocModel("B1");
Manager manager = new Manager(new StubBloc());
manager.DeleteBloc(bloc);
}
public void TestUpdateBloc()
{
BlocModel bloc = new BlocModel("B1");
Manager manager = new Manager(new StubBloc());
manager.UpdateBloc( bloc);
}
[Fact]
public void TestGetAllTEBloc()
{
BlocModel bloc = new BlocModel("B1");
Manager manager = new Manager(new StubBloc());
manager.GetAllBloc();
}
}
}

@ -11,48 +11,70 @@ namespace TestCalculateurMoyanne.LesTests
{
public class UnitTestBloc
{
// BlocModel b = new BlocModel();
// [Fact]
// public void Test()
// {
// Assert.NotNull(b);
// Assert.Equal("L3", b.Nom);
// Assert.NotEqual("E3", b.Nom);
// }
// [Fact]
// public void TestInvalidBloc()
// {
// Assert.Throws<ArgumentException>(() => new BlocModel(null));
// }
// public class Bloc_InlineData
// {
// [Theory]
// [InlineData(false, "L6", 2, "L3", 2)]
// [InlineData(false, "", 0, "", 0)]
// [InlineData(true, "M1", 0, "M1", 0)]
// public void TestConstructeur(bool isValid, string expectedNom, int expectedId,
// string Nom, int id)
// {
// if (!isValid)
// {
// Assert.Throws<ArgumentException>(() => new MaquetteModel(Nom, id));
// return;
// }
// BlocModel m = new BlocModel(Nom, id);
// Assert.Equal(expectedNom, m.Nom);
// Assert.Equal(expectedId, m.Id);
// }
// [Fact]
// public void TestBlocStub()
// {
// StubBloc stub = new StubBloc();
// // Assert.Equal(10, stub.GetAllUE(10).Result.Count());
// }
// }
BlocModel b = new BlocModel("B3");
[Fact]
public void Test()
{
Assert.NotNull(b);
Assert.Equal("B3", b.Nom);
Assert.NotEqual("E3", b.Nom);
}
[Fact]
public void TestInvalidBloc()
{
string nom=null;
Assert.Throws<ArgumentException>(() => new BlocModel(nom));
}
// public class Bloc_InlineData
// {
// [Theory]
// [InlineData(false, "L6", 2, "L3", 2)]
// [InlineData(false, "", 0, "", 0)]
// [InlineData(true, "M1", 0, "M1", 0)]
// public void TestConstructeur(bool isValid, string expectedNom, int expectedId,
// string Nom, int id)
// {
// if (!isValid)
// {
// Assert.Throws<ArgumentException>(() => new MaquetteModel(Nom, id));
// return;
// }
// BlocModel m = new BlocModel(Nom, id);
// Assert.Equal(expectedNom, m.Nom);
// Assert.Equal(expectedId, m.Id);
// }
// }
[Fact]
public void TestBlocStub()
{
StubBloc stub = new StubBloc();
Assert.Equal(10, stub.GetAllBloc(10).Result.Count());
}
[Fact]
public void TestRemove()
{
StubBloc stub = new StubBloc();
BlocModel e = new BlocModel("L1");
stub.Add(e);
stub.Delete(e);
//Compter le nombre de Maq dans un objet IEnumerable
Assert.Equal(0, stub.GetAll().Result.Count());
}
[Fact]
public void TestUpdate()
{
StubBloc stub = new StubBloc();
BlocModel e = new BlocModel("E1");
stub.Add(e);
e.setNom("L1");
stub.Update(e);
Assert.Equal("L1", stub.GetAll().Result.First().GetNom());
}
}

@ -16,8 +16,8 @@ namespace TestCalculateurMoyanne.LesTests
public void Test()
{
Assert.NotNull(m);
Assert.Equal("L3", m.GetNomMaquette());
Assert.NotEqual("E3", m.GetNomMaquette());
Assert.Equal("L3", m.NomMaquette);
Assert.NotEqual("E3", m.NomMaquette);
}
[Fact]
public void TestInvalidMaquette()
@ -25,23 +25,23 @@ namespace TestCalculateurMoyanne.LesTests
Assert.Throws<ArgumentException>(() => new MaquetteModel(null));
}
[Theory]
[InlineData(false, "L6" ,"L3")]
[InlineData(false, "", "")]
[InlineData(true, "M1", "M1" )]
public void TestConstructor(bool isValid, string expectedNomMaquette,
string NomMaquette)
{
if (!isValid)
{
Assert.Throws<ArgumentException>( () => new MaquetteModel(NomMaquette));
return;
}
//[Theory]
//[InlineData(false, "L6" ,"L3")]
//[InlineData(false, "", "")]
//[InlineData(true, "M1", "M1" )]
//public void TestConstructor(bool isValid, string expectedNomMaquette,
// string NomMaquette)
//{
// if (!isValid)
// {
// Assert.Throws<ArgumentException>( () => new MaquetteModel(NomMaquette));
// return;
// }
MaquetteModel m = new MaquetteModel(NomMaquette);
Assert.Equal(expectedNomMaquette, m.GetNomMaquette());
// MaquetteModel m = new MaquetteModel(NomMaquette);
// Assert.Equal(expectedNomMaquette, m.GetNomMaquette());
}
//}
// test avec stub
[Fact]
@ -68,7 +68,7 @@ namespace TestCalculateurMoyanne.LesTests
stub.Add(e);
e.setNomMaquete("L1");
stub.Update(e);
Assert.Equal("L1", stub.GetAll().Result.First().GetNomMaquette());
Assert.Equal("L1", stub.GetAll().Result.First().NomMaquette);
}
}

@ -13,141 +13,106 @@ namespace TestCalculateurMoyanne.LesTests
public class UnitTestUE
{
public static IEnumerable<object[]> Data_AddMatiereToUE()
UE u = new UE("f");
[Fact]
public void Test()
{
yield return new object[]
{
true,
new Matiere[]
{
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4),
new Matiere(4,12,"geo",2)
},
new UE(1,2,"UE2",
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4)),
new Matiere(4,12,"geo",2)
};
yield return new object[]
{
false,
new Matiere[]
{
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4),
new Matiere(4,12,"geo",2)
},
new UE(1,2,"UE2",
new Matiere( 1,20,"mat",2),
new Matiere(2,3,"histoire",4)),
new Matiere(4,12,"geo",2),
new Matiere(5,2,"arithmetique",3)
};
Assert.NotNull(u);
Assert.Equal("f", u.Intitulé);
Assert.NotEqual("oo", u.Intitulé);
}
[Fact]
public void testInvalid()
{
Assert.Throws<ArgumentException>(() => new UE(null));
}
[Fact]
public void Remove()
{
stubUE stub = new stubUE();
UE e = new UE("L1");
stub.Add(e);
stub.Delete(e);
//Compter le nombre de Maq dans un objet IEnumerable
Assert.Equal(0, stub.GetAll().Result.Count());
}
[Fact]
public void TestUpdate()
{
stubUE stub = new stubUE();
UE e = new UE("L1");
stub.Add(e);
e.setIntitulé("L1");
stub.Update(e);
Assert.Equal("L1", stub.GetAll().Result.First().GetIntitulé());
}
[Theory]
[MemberData(nameof(Data_AddMatiereToUE))]
public void Test_AddMatiereToUE(bool expectedResult,
IEnumerable<Matiere> expectedMatiere,
UE ue,
Matiere matiere) {
// true si l'ajout est réussi et false sinon
bool result = ue.AjouterMatiere(matiere);
// comparaison avec le resultat qu'on espert avoir
Assert.Equal(expectedResult, result);
}
}
//public static IEnumerable<object[]> Data_AddMatiereToUE()
//{
// yield return new object[]
// {
// true,
// new Matiere[]
// {
// new Matiere( 1,20,"mat",2),
// new Matiere(2,3,"histoire",4),
// new Matiere(4,12,"geo",2)
// },
// new UE(1,2,"UE2",
// new Matiere( 1,20,"mat",2),
// new Matiere(2,3,"histoire",4)),
// new Matiere(4,12,"geo",2)
// };
// yield return new object[]
// {
// false,
// new Matiere[]
// {
// new Matiere( 1,20,"mat",2),
// new Matiere(2,3,"histoire",4),
// new Matiere(4,12,"geo",2)
// },
// new UE(1,2,"UE2",
// new Matiere( 1,20,"mat",2),
// new Matiere(2,3,"histoire",4)),
// new Matiere(4,12,"geo",2),
// new Matiere(5,2,"arithmetique",3)
// };
//[Theory]
// [MemberData(nameof(Data_AddMatiereToUE))]
// public void Test_AddMatiereToUE(bool expectedResult,
// IEnumerable<Matiere> expectedMatiere,
// UE ue,
// Matiere matiere) {
//// true si l'ajout est réussi et false sinon
// bool result = ue.AjouterMatiere(matiere);
// // comparaison avec le resultat qu'on espert avoir
// Assert.Equal(expectedResult, result);
// //
// Assert.Equal(expectedMatiere.Count(), ue.Matieres.Count());
// Assert.All(expectedMatiere, j => ue.Matieres.Contains(j));
// }
//
Assert.Equal(expectedMatiere.Count(), ue.Matieres.Count());
Assert.All(expectedMatiere, j => ue.Matieres.Contains(j));
}
}
}
//true,
//new Artist[]
//{
// new Artist("Miles", "Davis"),
// new Artist("Wayne", "Shorter"),
// new Artist("Herbie", "Hancock"),
// new Artist("Ron", "Carter"),
// new Artist("Tony", "Williams")
//},
//new Album("Miles Smiles", new DateTime(1967, 1, 1),
// new Artist("Miles", "Davis"),
// new Artist("Wayne", "Shorter"),
// new Artist("Herbie", "Hancock"),
// new Artist("Ron", "Carter")),
//new Artist("Tony", "Williams")
//{
// [Theory]
// [InlineData(false, "Mathematique", 2, "MTH", 2)]
// [InlineData(false, "", 0, "", 0)]
// [InlineData(true, "Mathematique", 0, "Mathematique", 0)]
// public void TestConstructor(bool isValid, string expectedMatiere, int expectedcoef,
// string intitulé, int coefficient)
// {
// if (!isValid)
// {
// Assert.Throws<ArgumentException>(
// () => new UE(intitulé, coefficient));
// return;
// }
// UE e = new UE(intitulé, coefficient);
// Assert.Equal(expectedMatiere,e.Intitulé);
// Assert.Equal(expectedcoef, e.Coefficient);
// }
// // test avec stub
// [Fact]
// public void TestUeStub()
// {
// stubUE stub = new stubUE();
// Assert.Equal(10, stub.GetAllUE(10).Result.Count());
// }
// [Fact]
// public void TestRemove()
// {
// stubUE stub = new stubUE();
// UE e = new UE("E1");
// stub.Add(e);
// stub.Delete(e);
// //Compter le nombre de UE dans un objet IEnumerable
// Assert.Equal(0, stub.GetAll().Result.Count());
// }
// public void TestUpdate()
// {
// stubUE stub = new stubUE();
// UE e = new UE("E1");
// stub.Add(e);
// e.setIntitulé("UE1");
// stub.Update(e);
// Assert.Equal("UE1", stub.GetAll().Result.First().Intitulé);
// }
//}

@ -10,10 +10,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
@ -26,6 +26,7 @@
<ItemGroup>
<ProjectReference Include="..\..\CalculateurMoyanne\CalculateurStub\StubCalculateur.csproj" />
<ProjectReference Include="..\..\CalculateurMoyanne\ClassCalculateurMoyenne\ClassCalculateurMoyenne.csproj" />
<ProjectReference Include="..\..\CalculateurMoyanne\BSN\Bussness.csproj" />
</ItemGroup>
</Project>

Loading…
Cancel
Save