master
etudiant 3 years ago
parent b8374521d9
commit 575888267a

@ -0,0 +1,12 @@
using System;
using ClassCalculateurMoyenne;
namespace Bussness
{
public interface IBlocDbManager:IDataManager<BlocModel>
{
Task<IEnumerable<BlocModel>> GetByMaquette(MaquetteModel maquetteModel);
Task <bool> AddUeBloc(BlocModel bloc, UE uE);
}
}

@ -14,7 +14,7 @@ namespace Bussness
Task<bool> Update(Data data);
Task<Data> GetDataWithName(string name);
Task<List<Data>> GetAll();
Task<bool> AddUEBloc(UE data, int blocId);
}
}

@ -0,0 +1,10 @@
using System;
using ClassCalculateurMoyenne;
namespace Bussness
{
public interface IMatiereDbManager : IDataManager<Matiere>
{
Task<IEnumerable<Matiere>> GetAllMatiereUE(UE ue);
}
}

@ -0,0 +1,12 @@
using System;
using ClassCalculateurMoyenne;
namespace Bussness
{
public interface IUeDbDataManager:IDataManager<UE>
{
Task<IEnumerable<UE>> GetAllUEBloc(BlocModel bloc);
Task<bool> AddMatiereUe(UE uE, Matiere matiere);
}
}

@ -21,17 +21,19 @@ namespace Bussness
private readonly List<Matiere> matieres = new();
public MaquetteModel SelectedMaquetteModel { get; set; }
public BlocModel SelecteBlocModel { get; set; }
public UE SelectedUe { get; set; }
public IDataManager<MaquetteModel> MaquetteDbDataManager => maquetteDbDataManager;
private readonly IMaquetteDbManager maquetteDbDataManager;
public IDataManager<BlocModel> BlocDbDataManager => blocDbDataManager;
private readonly IDataManager<BlocModel> blocDbDataManager;
public IDataManager<UE> UeDbDataManager => ueDbDataManager;
private readonly IDataManager<UE> ueDbDataManager;
public IDataManager<Matiere> MatiereDbDataManager => matiereDbDataManager;
private readonly IDataManager<Matiere> matiereDbDataManager;
public IBlocDbManager BlocDbDataManager => blocDbDataManager;
private readonly IBlocDbManager blocDbDataManager;
public IUeDbDataManager UeDbDataManager => ueDbDataManager;
private readonly IUeDbDataManager ueDbDataManager;
public IMatiereDbManager MatiereDbDataManager => matiereDbDataManager;
private readonly IMatiereDbManager matiereDbDataManager;
#endregion
@ -44,23 +46,23 @@ namespace Bussness
maquette = new ReadOnlyCollection<MaquetteModel>(maquettes);
}
public Manager(IDataManager<BlocModel>blocmanager)
public Manager( IBlocDbManager blocmanager)
{
this.blocDbDataManager = blocmanager;
bloc = new ReadOnlyCollection<BlocModel>(blocs);
}
public Manager(IDataManager<UE> UeManager)
public Manager(IUeDbDataManager UeManager)
{
this.ueDbDataManager = UeManager;
ue = new ReadOnlyCollection<UE>(ues);
}
public Manager(IDataManager<Matiere> matiereDbDataManager)
public Manager(IMatiereDbManager matiereDbDataManager)
{
this.matiereDbDataManager = matiereDbDataManager;
matiere = new ReadOnlyCollection<Matiere>(matieres);
}
public Manager(IDataManager<Matiere> matiereManager,IDataManager<UE> UeManager, IDataManager<BlocModel> blocmanager, IMaquetteDbManager maquettemanager)
public Manager(IMatiereDbManager matiereManager, IUeDbDataManager UeManager, IBlocDbManager blocmanager, IMaquetteDbManager maquettemanager)
{
this.matiereDbDataManager = matiereManager;
matiere = new ReadOnlyCollection<Matiere>(matieres);
@ -127,28 +129,60 @@ namespace Bussness
return blocDbDataManager.Add(bloc);
}
public async Task<bool> AddBlocmaquette(MaquetteModel mqt, BlocModel blocModel)
public async Task <IEnumerable<BlocModel>> GetByMaquette(MaquetteModel maquetteModel)
{
var response = maquetteDbDataManager == null;
if (response)
//if (BlocDbDataManager==null)
//{
// return false; GetAllUEBloc
//}
return await blocDbDataManager.GetByMaquette(maquetteModel);
}
public async Task<IEnumerable<UE>> GetAllUEBloc(BlocModel bloc)
{
return await ueDbDataManager.GetAllUEBloc(bloc);
}
public async Task<IEnumerable<Matiere>> GetAllMatiereUE(UE ue)
{
return await matiereDbDataManager.GetAllMatiereUE(ue);
}
public async Task<bool> AddBlocmaquette(MaquetteModel mqt, BlocModel blocModel)
{
if (maquetteDbDataManager == null)
{
return false;
}
return await maquetteDbDataManager.AddBlocmaquette(mqt, blocModel);
}
public async Task<bool> AddUeBloc(BlocModel bloc, UE uE)
{
if (BlocDbDataManager == null)
{
return false;
}
return await blocDbDataManager.AddUeBloc(bloc, uE);
}
public async Task<bool> AddMatiereUe(UE uE, Matiere matiere)
{
if (UeDbDataManager == null)
{
return false;
}
return await ueDbDataManager.AddMatiereUe(uE, matiere);
}
//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)
@ -157,12 +191,24 @@ namespace Bussness
}
return await BlocDbDataManager.Delete(bl);
}
//public async Task<bool> DeleteBlocById(int id)
//{
//}
public async Task<bool> Deletee(Matiere bl)
{
if (MatiereDbDataManager == null)
{
return false;
}
return await MatiereDbDataManager.Delete(bl);
}
public async Task<bool> DeleteUe(UE data)
{
if (UeDbDataManager == null)
{
return false;
}
return await UeDbDataManager.Delete(data);
}
//Update bloc
public async Task<bool> UpdateBloc(BlocModel bl)
{
if (BlocDbDataManager == null)
@ -176,6 +222,19 @@ namespace Bussness
{
return await BlocDbDataManager.GetAll();
}
//getAllue
public async Task<IEnumerable<UE>> GetAllue()
{
return await ueDbDataManager.GetAll();
}
//getallmatieredansue
public async Task<IEnumerable<Matiere>> GetAllMatUE()
{
return await matiereDbDataManager.GetAll();
}
#endregion
}
}

@ -16,17 +16,18 @@ namespace CalculateurApp
// MainPage = new NavigationPage(new HomePage());
//MainPage = new AppShell(BlocViewModel c);
// MainPage = new EXE ();
// MainPage = new MatiereView ();
MainPage = new AppShell();
// MainPage = new BlockView();
// MainPage = new AppShell();
MainPage = new HomePage();
}
public Manager manager { get; set; } = new Manager( null, null, new BlocDbDataManager<CalculDbMaui>(), new MaquetteDbDataManager<CalculDbMaui>())
public Manager manager { get; set; } = new Manager( new MatiereDbDataManager<CalculDbMaui>(), new UeDbDataManager<CalculDbMaui>(), new BlocDbDataManager<CalculDbMaui>(), new MaquetteDbDataManager<CalculDbMaui>())
{
};

@ -84,24 +84,21 @@
<MauiXaml Update="View\MaquettePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\MatNote.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\PageUe.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\Start.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<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>
<MauiXaml Update="View\UeView.xaml">
<SubType></SubType>
</MauiXaml>
<MauiXaml Update="View\MatiereView.xaml">
<SubType></SubType>
</MauiXaml>
</ItemGroup>
<ItemGroup>
@ -109,11 +106,13 @@
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Images\dotnet_bot.svg" />
<BundleResource Include="Resources\Images\mamoyene.png" />
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.EntityFrameworkCore" />
<None Remove="Microsoft.EntityFrameworkCore.Tools" />
<None Remove="Microsoft.EntityFrameworkCore.Sqlite" />
<None Remove="sqlite-net-pcl" />
<None Remove="Resources\Images\mamoyene.png" />
</ItemGroup>
</Project>

@ -26,8 +26,9 @@ namespace CalculateurApp
builder.Services.AddSingleton<PageAjoutMaquette>();
builder.Services.AddTransient<Start>();
builder.Services.AddTransient<BlocViewModel>();
builder.Services.AddTransient<UeView>();
return builder.Build();
return builder.Build();
}
}
}

@ -4,8 +4,9 @@
x:Class="CalculateurApp.View.BlockView"
xmlns:viewmodel="clr-namespace:CalculateurApp.ViewModel"
x:DataType="viewmodel:MaquetteViewModel"
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="BlockView">
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="BlockView"
Loaded="ContentPage_Loaded">
<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".75*,.25*"
@ -14,10 +15,11 @@
ColumnSpacing="4">
<Entry Placeholder="Ajout de BLOC DANS LA MAQUETTE"
Grid.Row="1" BackgroundColor="AliceBlue"
Text=""
Text="{Binding Nom}"
x:Name="ajt"
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 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"
@ -27,9 +29,7 @@
VerticalOptions="Center"
WidthRequest="100"
>
</Button>
</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>
@ -42,8 +42,7 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MaquetteViewModel}}, Path=DeleteCommand}"
CommandParameter="{Binding .}"
/>
<SwipeItem Text="AFFICHER" BackgroundColor="BlueViolet"></SwipeItem>
<SwipeItem Text="MODIFIER UES" BackgroundColor="Beige"></SwipeItem>
<SwipeItem Text="AFFICHER" BackgroundColor="BlueViolet"></SwipeItem>
</SwipeItems>
</SwipeView.RightItems>
<Grid Padding="0">

@ -6,21 +6,33 @@ using Bussness;
namespace CalculateurApp.View;
public partial class BlockView : ContentPage
public partial class BlockView : ContentPage, IQueryAttributable
{
public Manager Manager => (Application.Current as App).manager;
public MaquetteViewModel mvm { get; set; }
public BlockView()
{
InitializeComponent();
var mvm = new MaquetteViewModel();
mvm = new MaquetteViewModel();
mvm.manager = Manager;
mvm.init1();
//mvm.init1();
BindingContext = mvm;
}
private async void Aer(object sender, EventArgs e)
{
//Navigation.PushAsync(new BlockView());
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
}
void ContentPage_Loaded(System.Object sender, System.EventArgs e)
{
mvm.init1();
}
}

@ -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"
x:Class="CalculateurApp.View.HomePage"
@ -6,14 +6,17 @@
android:TabbedPage.ToolbarPlacement="Bottom"
BarTextColor="LightSalmon"
SelectedTabColor="DarkRed"
UnselectedTabColor="DarkKhaki"
UnselectedTabColor="DarkKhaki"
BackgroundImageSource="mamoyene.png"
>
<ContentPage Title="CalculApp" IconImageSource="mamoyenne.png">
<ContentPage Title="CalculApp" IconImageSource="mamoyene.png">
<Grid RowDefinitions=".9*, .1*" >
<Button Text=" + " Clicked="Button_Clicked" HorizontalOptions="End" VerticalOptions="Start" />
<Label Text="Clique sur le Boutton + pour commencers "
HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" />
<Label Text="Clique sur le Boutton + pour commencers "
HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
<!--<Label Grid.Row="1" Text="Echec OU REUSSITE ,CE que l'on tente est mieux que le sommeil" HorizontalOptions="End" VerticalOptions="End"></Label>-->
</Grid>
</ContentPage>
<ContentPage Title="parametre" IconImageSource="png.png">

@ -46,7 +46,7 @@
</Button>-->
<CollectionView Grid.Row="3" Grid.ColumnSpan="1" ItemsSource="{Binding Items}" SelectionMode="Multiple" BackgroundColor="White">
<CollectionView Grid.Row="3" Grid.ColumnSpan="1" ItemsSource="{Binding Items}" SelectionMode="None" BackgroundColor="White">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:MaquetteModel }">
<SwipeView>

@ -16,4 +16,9 @@ public partial class AjtMaquette : ContentPage
BindingContext = vm;
Routing.RegisterRoute(nameof(BlockView), typeof(BlockView));
}
private void affichagedesbloks(object sender, EventArgs e)
{
Navigation.PushAsync(new BlockView());
}
}

@ -0,0 +1,102 @@
<?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.MatiereView"
xmlns:viewmodel="clr-namespace:CalculateurApp.ViewModel"
x:DataType="viewmodel:UeViewModel"
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="MatiereView"
Loaded="ContentPage_Loaded">
<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".225*,.225*"
Padding="10"
RowSpacing="10"
ColumnSpacing="4"
>
<Label Text=" Note:" VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150" ></Label>
<Entry Text="{Binding ma.Note}" Placeholder="note" HorizontalOptions="End"
VerticalOptions="Center" WidthRequest="60" ></Entry>
<Label Grid.Column="2" Text="/" HorizontalOptions="Center"
VerticalOptions="Center" WidthRequest="60"></Label>
<Label Grid.Column="3" Text="20" HorizontalOptions="End"
VerticalOptions="Center"></Label>
<Label Text="coefficent" Grid.Row="1"
VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150"></Label>
<Entry Grid.Row="1" Text="{Binding ma.Coef}"
VerticalOptions="Center" HorizontalOptions="End" WidthRequest="60" ></Entry>
<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>
<Button
Command="{Binding AddCommand}"
Text="ajouter"
Grid.Row="2"
Grid.Column="4"
HorizontalOptions="End"
VerticalOptions="Start"
WidthRequest="100"
>
</Button>
<CollectionView Grid.Row="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:Matiere }">
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Text="Delete"
BackgroundColor="Red"
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:UeViewModel}}, Path=DeleteCommand}"
CommandParameter="{Binding .}"
/>
<SwipeItem Text="AFFICHER" BackgroundColor="BlueViolet"></SwipeItem>
</SwipeItems>
</SwipeView.RightItems>
<Grid Padding="0">
<Frame Grid.Row="1">
<Grid Padding="10" ColumnSpacing="40">
<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="{Binding Nommatiere}"
FontAttributes="None"
VerticalOptions="End"/>
<Label Grid.Column="2"
Grid.Row="1"
Text="{Binding Note}"
TextColor="Blue"
FontAttributes="Bold" />
<Label Grid.Column="3"
Grid.Row="1"
Text="20"
TextColor="Blue"
FontAttributes="Bold" />
<Label Grid.Column="4"
Grid.Row="1"
Text="{Binding Coef}"
TextColor="Blue"
FontAttributes="Bold" />
</Grid>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView >
</Grid>
</ContentPage>

@ -0,0 +1,27 @@
using CalculateurApp.ViewModel;
namespace CalculateurApp.View;
using Bussness;
public partial class MatiereView : ContentPage
{
public Manager Manager => (Application.Current as App).manager;
public UeViewModel mvm { get; set; }
public MatiereView()
{
InitializeComponent();
mvm = new UeViewModel();
mvm.manager = Manager;
mvm.init1();
BindingContext = mvm;
}
void ContentPage_Loaded(System.Object sender, System.EventArgs e)
{
//mvm.init1();
}
//private async void pop(object sender, EventArgs e)
//{
// string result = await DisplayPromptAsync("Question 2", "What's 5 + 5?", initialValue: "10", maxLength: 2, keyboard: Keyboard.Numeric);
//}
}

@ -8,7 +8,7 @@ public partial class Start : TabbedPage
public Start()
{
InitializeComponent();
BindingContext = new BlocViewModel();
//BindingContext = new BlocViewModel();
}
public async void ok(object sender, EventArgs e)
{

@ -0,0 +1,102 @@
<?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"
x:DataType="viewmodel:BlocViewModel"
x:Class="CalculateurApp.View.UeView"
xmlns:model="clr-namespace:ClassCalculateurMoyenne;assembly=ClassCalculateurMoyenne"
Title="UeView"
Loaded="ContentPage_Loaded">
<Grid RowDefinitions="100 ,Auto,*"
ColumnDefinitions=".75*,.25*"
Padding="10"
RowSpacing="10"
ColumnSpacing="4"
>
<Entry Placeholder="Ajout de UE "
Grid.Row="1"
BackgroundColor="AliceBlue"
Text="{Binding Intitulé}"
TextColor="Black"
WidthRequest="150"
HorizontalOptions="Start"
VerticalOptions="StartAndExpand"
/>
<Entry
Placeholder="coef"
WidthRequest="60"
Grid.Row="1"
HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="AliceBlue"
Text="{Binding ue.Coefficient}">
</Entry>
<Button
Command="{Binding AddCommand}"
Text="Ajouter"
Grid.Row="1"
Grid.Column="1"
HorizontalOptions="End"
VerticalOptions="Center"
>
</Button>
<CollectionView Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding Items}" SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type model:UE }">
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Text="Delete"
BackgroundColor="Red"
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:BlocViewModel}}, Path=DeleteCommand}"
CommandParameter="{Binding .}"
/>
<SwipeItem Text="AFFICHER" BackgroundColor="BlueViolet"></SwipeItem>
</SwipeItems>
</SwipeView.RightItems>
<Grid Padding="0">
<Frame Grid.Row="1">
<Frame.GestureRecognizers >
<TapGestureRecognizer
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:BlocViewModel}}, Path=TappCommand}"
CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Grid Padding="10" ColumnSpacing="40">
<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="{Binding Intitulé}"
FontAttributes="None"
VerticalOptions="End"/>
<Label Grid.Column="3"
Grid.Row="1"
Text="{Binding Coefficient}"
TextColor="Blue"
FontAttributes="Bold" />
</Grid>
</Frame>
</Grid>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView >
</Grid>
</ContentPage>

@ -0,0 +1,34 @@

using Bussness;
using CalculateurApp.ViewModel;
namespace CalculateurApp.View;
public partial class UeView : ContentPage
{
public Manager Manager => (Application.Current as App).manager;
public BlocViewModel mv { get; set; }
public UeView()
{
InitializeComponent();
mv = new BlocViewModel();
mv.manager = Manager;
BindingContext = mv;
mv.init1();
}
void ContentPage_Loaded(System.Object sender, System.EventArgs e)
{
mv.init1();
}
void ContentPage_Loaded_1(System.Object sender, System.EventArgs e)
{
}
void ContentPage_Loaded_2(System.Object sender, System.EventArgs e)
{
}
}

@ -6,78 +6,120 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Bussness;
using System.Threading.Tasks;
using System.Diagnostics;
using CalculateurApp.View;
namespace CalculateurApp.ViewModel
namespace CalculateurApp.ViewModel;
public partial class BlocViewModel:ObservableObject,IQueryAttributable
{
public partial class BlocViewModel:ObservableObject,IQueryAttributable
public UE ue { get; set; }
public Manager manager { get; set; }
public BlocViewModel()
{
Routing.RegisterRoute(nameof(MatiereView), typeof(MatiereView));
//ue = new UE();
// Items = new ObservableCollection<UE>();
}
public void init1()
{
Items = new ObservableCollection<UE>();
[ObservableProperty]
string nom;
public BlocModel blocModel { get; set; }
public UE ue { get; set; }
public BlocViewModel()
try
{
Items = new ObservableCollection<UE>();
blocModel=new BlocModel();
ue = new UE();
GEtAllUE();
ue = new UE();
}
[ObservableProperty]
ObservableCollection<UE> items;
[ObservableProperty]
string intitulé;
[RelayCommand]
void Add()
catch (Exception ex)
{
if (string.IsNullOrEmpty(ue.Intitulé)&& string.IsNullOrEmpty(ue.Coefficient.ToString()))
return;
UE u = new UE(ue.Intitulé,ue.Coefficient);
//u.Intitulé = ue.Intitulé;
Items.Add(u);
ue.Intitulé = string.Empty;
ue.Coefficient = 0;
Debug.WriteLine(ex);
}
[RelayCommand]
void Delete(UE bl)
ue = new UE();
}
[ObservableProperty]
ObservableCollection<UE> items;
[ObservableProperty]
string intitulé;
[RelayCommand]
async void Add()
{
if (string.IsNullOrEmpty(Intitulé)&& string.IsNullOrEmpty(ue.Coefficient.ToString()))
return;
// ue.Intitulé = Intitulé;
UE u = new UE(Intitulé, ue.Coefficient);
Items.Add(u);
await manager.AddUeBloc(manager.SelecteBlocModel, u);
}
[RelayCommand]
async void Delete(UE bl)
{
if (Items.Contains(bl))
{
if (Items.Contains(bl))
{
Items.Remove(bl);
}
Items.Remove(bl);
await manager.DeleteUe(bl);
var y = await manager.GetAllue();
}
[RelayCommand]
void GEtAllUE(UE bl)
}
[RelayCommand]
async Task Tapp(UE ue)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
}
}
// 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);
[RelayCommand]
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
manager.SelectedUe = ue;
var parametre = new Dictionary<string, Object>
{
{"matiere",ue}
};
await Shell.Current.GoToAsync($"{nameof(MatiereView)}", parametre);
public void ApplyQueryAttributes(IDictionary<string, object> query)
}
[RelayCommand]
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
//page
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
var bloc = query["ue"] as BlocModel;
var ueList = bloc.ue;
ue.IDForeignKey = bloc.Id;
}
[RelayCommand]
void GEtAllUE()
{
items.Clear();
var result = manager.GetAllUEBloc(manager.SelecteBlocModel);
foreach (var item in result.Result)
{
var Maquette = query["maquette"]as MaquetteModel ;
items.Add(item);
blocModel.IDMaquetteFrk = Maquette.Id;
}
}
}
}

@ -15,138 +15,119 @@ using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
namespace CalculateurApp.ViewModel;
public partial class MaquetteViewModel:ObservableObject
namespace CalculateurApp.ViewModel
{
public BlocModel blocModel { get; set; }
// public ReadOnlyObservableCollection<BlocModel>lst { get; set; }
public Manager manager { get; set; }
public MaquetteViewModel()
public partial class MaquetteViewModel:ObservableObject
{
//Items = new ObservableCollection<BlocModel>();
//try
//{
// foreach (var BB in manager.GetAllBloc().Result)
// Items.Add(BB);
//}
//catch (Exception ex)
//{
// Debug.WriteLine(ex);
//}
public BlocModel blocModel { get; set; }
//public ReadOnlyObservableCollection<BlocModel>lst { get; set; }
public Manager manager { get; set; }
//blocModel = new BlocModel();
}
public void init1()
{
Items = new ObservableCollection<BlocModel>();
try
{
foreach (var BB in manager.GetAllBloc().Result)
Items.Add(BB);
public MaquetteViewModel()
{ //route
Routing.RegisterRoute(nameof(UeView), typeof(UeView));
}
catch (Exception ex)
public void init1()
{
Debug.WriteLine(ex);
}
Items = new ObservableCollection<BlocModel>();
try
{
GetAllBloc();
blocModel = new BlocModel();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
blocModel = new BlocModel();
}
[ObservableProperty]
ObservableCollection<BlocModel> items;
[ObservableProperty]
ObservableCollection<BlocModel> lstblc=new ObservableCollection<BlocModel>();
[ObservableProperty]
string nom;
[RelayCommand]
async void Add()
{
// Manager blocDbDataManager = new Manager(new BlocDbDataManager<CalculDbMaui>());
if (string.IsNullOrEmpty(blocModel.Nom))
return;
//BlocModel u = blocModel;
//MaquetteModel u = new MaquetteModel();
Items.Add(blocModel);
await manager.AddBlocmaquette(manager.SelectedMaquetteModel, blocModel);
}
[RelayCommand]
async void Delete(BlocModel bl)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
await manager.DeleteBloc(bl);
var o = await manager.GetAllBloc();
blocModel = new BlocModel();
}
[ObservableProperty]
ObservableCollection<BlocModel> items;
[ObservableProperty]
string nom;
//if (Items.Contains(model))
//{
// Items.Remove(model);
// await manager.Deletemqt(model);
// var v = await manager.GetAllMaquette();
// Console.WriteLine(v);
[RelayCommand]
async void Add()
{
if (string.IsNullOrEmpty(Nom))
return;
blocModel.Nom = Nom;
Items.Add(blocModel);
await manager.AddBlocmaquette(manager.SelectedMaquetteModel, blocModel);
}
[RelayCommand]
async void Delete(BlocModel bl)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
await manager.DeleteBloc(bl);
var o = await manager.GetAllBloc();
}
//}
}
[RelayCommand]
void AjoutUE(BlocModel bl)
}
[RelayCommand]
void AjoutUE(BlocModel bl)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
if (Items.Contains(bl))
{
Items.Remove(bl);
}
}
}
[RelayCommand]
async Task Tap(String s)
{
await Shell.Current.GoToAsync($"{nameof(UE)}?Nom={s}");
[RelayCommand]
async Task Tap(BlocModel blocModel)
{
// 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);
}
[RelayCommand]
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
}
[RelayCommand]
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
var Maquette = query["maquette"] as MaquetteModel;
public void ApplyQueryAttributes(IDictionary<string, object> query)
blocModel.IDMaquetteFrk = Maquette.Id;
}
[RelayCommand]
public void GetAllBloc()
{
{
var result = manager.GetAllBloc();
foreach(var item in result.Result)
{
lstblc.Add(item);
var Maquette = query["maquette"] as MaquetteModel;
blocModel.IDMaquetteFrk = Maquette.Id;
}
}
[RelayCommand]
public void GetAllBloc()
{
items.Clear();
[RelayCommand]
public void Blocview(IEnumerable<BlocModel> blocModels)
{
//items.Add
var result = manager.GetByMaquette(manager.SelectedMaquetteModel);
foreach(var item in result.Result)
{
items.Add(item);
}
}
}
}

@ -0,0 +1,11 @@
using System;
namespace CalculateurApp.ViewModel
{
public class MatiereViewModel
{
public MatiereViewModel()
{
}
}
}

@ -14,16 +14,11 @@ namespace CalculateurApp.ViewModel
{
public MaquetteModel maquette { get; set; }
public Manager manager { get; set; }
public PageAjoutMaquette()
{
//manager = new Manager(new MaquetteDbDataManager<CalculDbMaui>());
}
public void Init()
{
Items = new ObservableCollection<MaquetteModel>();
@ -43,14 +38,12 @@ namespace CalculateurApp.ViewModel
[RelayCommand]
async void Add()
{
//Manager maquetteDbDataManager = new Manager(new MaquetteDbDataManager<CalculDbMaui>());
if (string.IsNullOrEmpty(NomMaquette))
return;
MaquetteModel u = maquette;
Items.Add(u);
await manager.AddMaquette(maquette);
//maquette.NomMaquette = string.Empty;
}
[RelayCommand]
@ -75,21 +68,17 @@ namespace CalculateurApp.ViewModel
async void GetAllMaquette()
{
//Manager maquetteDbDataManager = new Manager(new MaquetteDbDataManager<CalculDbMaui>());
await manager.GetAllMaquette();
}
[RelayCommand]
async Task Tap(MaquetteModel maquetteName)
{
manager.SelectedMaquetteModel = maquetteName;
var maquette = manager.GetMaquetteByName(maquetteName.NomMaquette);
async Task Tap(MaquetteModel maquette)
{
manager.SelectedMaquetteModel = maquette;
var parametre = new Dictionary<string, Object>
{
{"maquette",maquette}
{"blocs",maquette.BLOCS}
};
await Shell.Current.GoToAsync($"{nameof(BlockView)}",parametre);
await Shell.Current.GoToAsync($"{nameof(BlockView)}",parametre);
}
}

@ -5,70 +5,107 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Bussness;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace CalculateurApp.ViewModel
{
//[QueryProperty("Nom", "Nom")]
public partial class UeViewModel:ObservableObject
public partial class UeViewModel:ObservableObject, IQueryAttributable
{
//[ObservableProperty]
//string nom;
public UE u { get; set; }
public Matiere ma { get; set; }
public Manager manager { get; set; }
public Matiere ma { get; set; }
public UeViewModel()
{
Tems = new ObservableCollection<Matiere>();
//Items = new ObservableCollection<Matiere>();
// ma = new Matiere();
//init1();
}
public void init1()
{
Items = new ObservableCollection<Matiere>();
try
{
GEtAllMatiere();
ma = new Matiere();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
ma = new Matiere();
u = new UE();
}
public string Nommatiere
{
get => ma.Nommatiere;
set => SetProperty(ma.Nommatiere, value, ma, (u, v) => u.Nommatiere=v);
}
[ObservableProperty]
ObservableCollection<Matiere> items;
[ObservableProperty]
ObservableCollection<Matiere> tems;
[ObservableProperty]
string coefficient;
int coefficient;
[ObservableProperty]
string nommatiere;
int note;
[RelayCommand]
void Add()
async void Add()
{
if (string.IsNullOrEmpty(ma.Nommatiere))
return;
Matiere m = new Matiere(ma.Nommatiere);
Matiere m = new Matiere(ma.Note, ma.Nommatiere, ma.Coef);
Items.Add(m);
ma.Nommatiere = string.Empty;
await manager.AddMatiereUe(manager.SelectedUe, m);
}
[RelayCommand]
void AddCoefUE()
async void Delete(Matiere bl)
{
if (Items.Contains(bl))
{
Items.Remove(bl);
await manager.Deletee(bl);
var y = await manager.GetAllMatUE();
}
}
[RelayCommand]
void Delete(Matiere bl)
void GEtAllMatiere()
{
if (Items.Contains(bl))
items.Clear();
var result = manager.GetAllMatiereUE(manager.SelectedUe);
foreach (var item in result.Result)
{
Items.Remove(bl);
items.Add(item);
}
}
//[RelayCommand]
//async Task GoBack()
//{
// await Shell.Current.GoToAsync("..");
//}
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
var Ue = query["matiere"] as UE;
var MATList = Ue.Matieres;
ma.IDUEForeignKey = Ue.Id;
//var bloc = query["ue"] as BlocModel;
//var ueList = bloc.ue;
//ue.IDForeignKey = bloc.Id;
}
}
}

@ -10,9 +10,10 @@ namespace CalculateurEF.Entities
public class MatiereEntity
{
public string Nommatiere { get; set; }
public long id { get; set; }
public long Id { get; set; }
public int Note { get; set; }
public int Coef { get; set; }
public long IDUEForeignKey
{
get; set;
@ -23,5 +24,7 @@ namespace CalculateurEF.Entities
get; set;
}
}
}

@ -4,6 +4,7 @@ using CalculateurEF.Entities;
using ClassCalculateurMoyenne;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -12,7 +13,7 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class BlocDbDataManager<TContext>: IDataManager<BlocModel> where TContext :CalculContext,new()
public class BlocDbDataManager<TContext>: IBlocDbManager where TContext :CalculContext,new()
{//ajout de bloc
public async Task<bool> Add(BlocModel blc)
{
@ -57,14 +58,28 @@ namespace CalculateurMapping
}
return true;
}
public async Task<bool>GetByMaquette(MaquetteModel maquette) {
public async Task<IEnumerable<BlocModel>>GetByMaquette(MaquetteModel maquetteModel) {
List<BlocModel> blocModels = new List<BlocModel>();
using (var context = new TContext())
{
//
var maq = await context.Maquettes.Include(m => m.Bloc)
.SingleOrDefaultAsync(x => x.Id == maquetteModel.Id);
if (maq == null) return new List<BlocModel>();
foreach (var e in maq.Bloc)
{
blocModels.Add(new BlocModel
{
Id = e.Id,
Nom = e.Nom,
IDMaquetteFrk = e.IDMaquetteFrk,
});
}
return blocModels.AsEnumerable<BlocModel>();
}
return true;
}
@ -81,24 +96,25 @@ namespace CalculateurMapping
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);
}
}
//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;
}
}
// return ls;
// }
//}
public async Task<BlocModel> GetDataWithName(string name)
{
@ -129,21 +145,53 @@ namespace CalculateurMapping
return result;
}
public async Task<bool> AddUEBloc(UE data,int blocId)
{//addUedansbloc
bool resultat = false;
//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)
{
bool result = false;
using (var context = new TContext())
{
UEentity entity = new UEentity
BlocEntity data = await context.Bloc.FindAsync(bloc.Id);
if (data != null)
{
intitulé = data.Intitulé,
IDForeignKey = blocId,
};
context.Ue.Add(entity);
await context.SaveChangesAsync();
resultat = true;
return resultat;
UEentity entity = new UEentity
{
Id=uE.Id,
intitulé = uE.Intitulé,
Coefficient=uE.Coefficient,
BlocEntity = new BlocEntity
{
Id = bloc.Id,
Nom = bloc.Nom
},
};
if (!data.UeEntityId.Contains(entity))
{
data.UeEntityId.Add(entity);
context.Bloc.Update(data);
result = await context.SaveChangesAsync() > 0;
}
}
return result;
}
}
}
}

@ -40,8 +40,7 @@ namespace CalculateurMapping
//ajt de bloc
public async Task<bool> AddBlocmaquette(MaquetteModel mqt,BlocModel blocModel)
{ //Add mqt
{
bool result = false;
using (var context = new TContext())
{
@ -57,21 +56,15 @@ namespace CalculateurMapping
Id = mqt.Id,
NomMaquette = mqt.NomMaquette
},
};
if (!data.Bloc.Contains(entity))
{
data.Bloc.Add(entity);
// await context.Maquettes.AddAsync(data);
// Console.WriteLine("jyij");
context.Maquettes.Update(data);
result = await context.SaveChangesAsync() > 0;
data.Bloc.Add(entity);
context.Maquettes.Update(data);
result = await context.SaveChangesAsync() > 0;
}
}
//context.Database.EnsureCreated();
return result;
}
@ -114,25 +107,7 @@ namespace CalculateurMapping
return result;
}
//public async Task<IEnumerable<MaquetteModel>> GetAll()
//{
// using (var context = new CalculContext())
// {
// return await context.Maquettes.Select(I => new MaquetteModel
// (
// I.Id,
// I.NomMaquette,
// I.Bloc.Select(u =>
// u.ue.Select(uee => new UE(uee.Id, uee.Coefficient, uee.intitulé,
// uee.mat.Select(ma => new Matiere(ma.id, ma.Note,ma.Nommatiere,ma.Coef)).ToArray()
// )).ToList()
// ),
// I.Bloc.Select(j => new BlocModel(j.Nom)).ToArray()
// )).ToListAsync();
// }
// return null;
// }
public async Task<MaquetteModel> GetDataWithName(string name)
{
@ -177,9 +152,6 @@ namespace CalculateurMapping
}
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}
}

@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class MatiereDbDataManager : IDataManager<Matiere>
public class MatiereDbDataManager<TContext> :IMatiereDbManager where TContext : CalculContext, new()
{ //Maping entre la classe Matier et MatiereEntity
public async Task<bool> Add(Matiere data)
{
@ -20,7 +20,7 @@ namespace CalculateurMapping
{
MatiereEntity entity = new MatiereEntity
{
Nommatiere = data.GetNommatiere(),
Nommatiere = data.Nommatiere,
};
context.matier.Add(entity);
@ -39,27 +39,30 @@ namespace CalculateurMapping
public async Task<bool> Delete(Matiere mat)
{
bool result = false;
using (var Context = new CalculContext())
using (var Context = new TContext())
{
MatiereEntity entity = Context.matier.Find(mat.GetNommatiere());
MatiereEntity entity = Context.matier.Find(mat.Id);
Context.matier.Remove(entity);
result = await Context.SaveChangesAsync() > 0;
}
return result;
}
public async Task<List<Matiere>> GetAll()
{
using (var context = new CalculContext())
using (var context = new TContext())
{
return await context.matier.Select(e => new Matiere
(e.id,
(e.Id,
e.Note,
e.Nommatiere,
e.Coef
)).ToListAsync();
}
}
public Task<Matiere> GetDataWithName(string name)
{
@ -82,5 +85,32 @@ namespace CalculateurMapping
}
public async Task<IEnumerable<Matiere>> GetAllMatiereUE(UE ue)
{
List<Matiere> ls = new List<Matiere>();
using (var context = new TContext())
{
var BLC = await context.Ue.Include(m => m.mat)
.SingleOrDefaultAsync(x => x.Id == ue.Id);
if (BLC == null) return new List<Matiere>();
foreach (var e in BLC.mat)
{
ls.Add(new Matiere
{
Id=e.Id,
Note=e.Note,
Nommatiere=e.Nommatiere,
Coef=e.Coef
});
}
}
return ls;
}
}
}

@ -12,12 +12,49 @@ using System.Threading.Tasks;
namespace CalculateurMapping
{
public class UeDbDataManager : IDataManager<UE>
public class UeDbDataManager<TContext> : IUeDbDataManager where TContext:CalculContext,new ()
{
public async Task<bool> AddMatiereUe( UE uE,Matiere matiere)
{
bool result = false;
using (var context = new TContext())
{
UEentity data = await context.Ue.FindAsync(uE.Id);
if (data != null)
{
MatiereEntity entity = new MatiereEntity
{
Id = matiere.Id,
Note=matiere.Note,
Nommatiere = matiere.Nommatiere,
Coef = matiere.Coef,
UEentity = new UEentity
{
Id = uE.Id,
intitulé = uE.Intitulé
},
};
if (!data.mat.Contains(entity))
{
data.mat.Add(entity);
context.Ue.Update(data);
result = await context.SaveChangesAsync() > 0;
}
}
return result;
}
}
public async Task<bool> Add(UE data)
{
bool resultat = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
UEentity entity = new UEentity
{
@ -36,29 +73,22 @@ namespace CalculateurMapping
}
return resultat;
}
}
public Task<bool> AddUEBloc(UE data, int blocId)
{
throw new NotImplementedException();
}
}
public async Task<bool> Delete(UE data)
{
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
UEentity entity = context.Ue.Find(data.Intitulé);
UEentity entity = context.Ue.Find(data.Id);
context.Ue.Remove(entity);
result = await context.SaveChangesAsync() > 0;
}
return true;
}
public async Task<List<UE>> GetAll()
{
using (var context = new CalculContext())
using (var context = new TContext())
{
return await context.Ue.Select(e => new UE
(
@ -69,7 +99,6 @@ namespace CalculateurMapping
)).ToListAsync();
}
}
public Task<UE> GetDataWithName(string name)
{
throw new NotImplementedException();
@ -78,7 +107,7 @@ namespace CalculateurMapping
public async Task<bool> Update(UE data)
{
bool result = false;
using (var context = new CalculContext())
using (var context = new TContext())
{
UEentity entity = context.Ue.Find(data.Id);
entity.intitulé = data.Intitulé;
@ -90,5 +119,30 @@ namespace CalculateurMapping
}
return result;
}
public async Task<IEnumerable<UE>> GetAllUEBloc(BlocModel bloc)
{
List<UE> ls=new List<UE>();
using (var context = new TContext())
{
var BLC = await context.Bloc.Include(m => m.UeEntityId)
.SingleOrDefaultAsync(x => x.Id == bloc.Id);
if (BLC == null) return new List<UE>();
foreach (var e in BLC.UeEntityId)
{
ls.Add(new UE
{
Id = e.Id,
Intitulé = e.intitulé,
Coefficient=e.Coefficient,
IDForeignKey = e.IDForeignKey,
});
}
}
return ls;
}
}
}

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub
{
public class StubBloc: IDataManager<BlocModel>
public class StubBloc: IBlocDbManager
{
private List<BlocModel> listb = new List<BlocModel>();
public List<UE> ue = new List<UE>();
@ -86,6 +86,16 @@ namespace StubCalculateur.Stub
{
throw new NotImplementedException();
}
public Task<IEnumerable<BlocModel>> GetByMaquette(MaquetteModel maquetteModel)
{
throw new NotImplementedException();
}
public Task<bool> AddUeBloc(BlocModel bloc, UE uE)
{
throw new NotImplementedException();
}
}

@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace StubCalculateur.Stub
{
public class stubUE : IDataManager<UE>
public class stubUE : IUeDbDataManager
{
private List<UE> listUE = new List<UE>();
private List<Matiere> mat = new List<Matiere>();
@ -81,5 +81,15 @@ namespace StubCalculateur.Stub
{
throw new NotImplementedException();
}
public Task<IEnumerable<UE>> GetAllUEBloc(BlocModel bloc)
{
throw new NotImplementedException();
}
public Task<bool> AddMatiereUe(UE uE, Matiere matiere)
{
throw new NotImplementedException();
}
}
}

@ -21,7 +21,7 @@ namespace ClassCalculateurMoyenne
public int Id
{
get;
private set;
set;
}
public void setNom(string value)
{
@ -73,19 +73,7 @@ namespace ClassCalculateurMoyenne
Id = id;
this.uEs = uEs;
}
//public int ueForeignKey
//{
// get; set;
//}
//[ForeignKey("ueForeignKey")]
//public UE UE
//{
// get; set;
//}
//public BlocModel(string v)
//{
//}
public BlocModel()
{

@ -7,26 +7,51 @@ using System.Threading.Tasks;
namespace ClassCalculateurMoyenne
{
public class Matiere
public partial class Matiere : ObservableObject, IEquatable<Matiere>
{
public long Id { get; set; }
public string Nommatiere;
public int Note { get; private set; }
public int Coef { get; private set; }
public string GetNommatiere()
public long IDUEForeignKey { get; set; }
[ObservableProperty]
private int note;
[ObservableProperty]
private int coef;
private string nommatiere;
public string Nommatiere
{
return Nommatiere;
}
get { return nommatiere; }
set
{
if (string.IsNullOrWhiteSpace(value))
private void SetNomMaquette(string value)
{
this.Nommatiere = value;
{
throw new ArgumentException("Le Nom de la maquette est obligatoire");
}
nommatiere = value;
}
}
//public void setNomMatier(string value)
//{
// Nommatiere = value;
//}
//private void SetNomMaquette(string value)
//{
// if (string.IsNullOrEmpty(value))
public Matiere(long id ,int note, string nommatiere, int coef)
// {
// throw new ArgumentException("Nommatiere est obligatoire");
// }
// this.Nommatiere = value;
//}
public Matiere(long id, int note, string nommatiere, int coef)
{
Id = id;
Coef = coef;
@ -34,6 +59,16 @@ namespace ClassCalculateurMoyenne
Note = note;
}
public Matiere( int note, string nommatiere, int coef)
{
Coef = coef;
Nommatiere = nommatiere;
Note = note;
}
public Matiere(string nommatiere)
{
Nommatiere = nommatiere;
@ -45,7 +80,26 @@ namespace ClassCalculateurMoyenne
public override string ToString()
{
return $"{Nommatiere},{Note},{Coef}";
return $"{Id},{Nommatiere},{Note},{Coef}";
}
public bool Equals(Matiere other)
{
return Nommatiere.Equals(other.Nommatiere);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (GetType() != obj.GetType()) return false;
return Equals(obj as Matiere);
}
public override int GetHashCode()
{
return Nommatiere.GetHashCode();
}
}
}

@ -10,7 +10,6 @@ namespace ClassCalculateurMoyenne
[ObservableProperty]
private int coefficient;
[ObservableProperty]
private string intitulé;
public int IDForeignKey { get; set; }
@ -67,7 +66,7 @@ namespace ClassCalculateurMoyenne
public bool Equals(UE other)
{
return matieres.Equals(other.matieres);
return Intitulé.Equals(other.GetIntitulé());
}
public override bool Equals(object obj)
{
@ -78,7 +77,7 @@ namespace ClassCalculateurMoyenne
}
public override int GetHashCode()
{
return Matieres.GetHashCode();
return intitulé.GetHashCode();
}
public IEnumerable<Matiere> AjouterMatiere(params Matiere[] matieres)
{
@ -108,11 +107,8 @@ namespace ClassCalculateurMoyenne
{
matieres.Remove(matiere);
}
//public void ajtCoef(int Coefficient)
//{
// UE.Add(Coefficient);
//}
}
}

@ -6,57 +6,21 @@ using Xunit;
namespace TestCalculateurMoyanne.LesTests
{
public class TestManager
public class Test
{
[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);
Matiere m = new Matiere(2, "ALGO", 3);
}
[Fact]
public void TestDELETEBloc()
public void TestONS()
{
BlocModel bloc = new BlocModel("B1");
Manager manager = new Manager(new StubBloc());
manager.DeleteBloc(bloc);
Assert.NotNull(m);
Assert.Equal(2, m.Note);
Assert.Equal("ALGO", m.Nommatiere);
Assert.Equal(3, m.Coef);
Assert.NotEqual(21, m.Note);
Assert.NotEqual("GO", m.Nommatiere);
Assert.NotEqual(33, m.Coef);
}
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();
}
}
}
}

@ -4,8 +4,6 @@ using ClassCalculateurMoyenne;
using Bussness;
using Xunit;
namespace TestCalculateurMoyanne.LesTests
{
public class TestManager

@ -27,26 +27,6 @@ namespace TestCalculateurMoyanne.LesTests
}
// 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()
{

@ -25,25 +25,7 @@ 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;
// }
// MaquetteModel m = new MaquetteModel(NomMaquette);
// Assert.Equal(expectedNomMaquette, m.GetNomMaquette());
//}
// test avec stub
[Fact]
public void TestMaquetteStub()
{

@ -17,7 +17,7 @@ namespace TestCalculateurMoyanne.LesTests
[Fact]
public void Test()
{
Assert.NotNull(u);
Assert.NotNull(u);
Assert.Equal("f", u.Intitulé);
Assert.NotEqual("oo", u.Intitulé);
}

Loading…
Cancel
Save