diff --git a/src/CalculateurMoyanne/BSN/IDataManager.cs b/src/CalculateurMoyanne/BSN/IDataManager.cs index 105d555..03a6730 100644 --- a/src/CalculateurMoyanne/BSN/IDataManager.cs +++ b/src/CalculateurMoyanne/BSN/IDataManager.cs @@ -10,7 +10,6 @@ namespace Bussness public interface IDataManager { Task Add(Data data); - Task Delete(Data data); Task Update(Data data); Task GetDataWithName(string name); diff --git a/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml b/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml index 50dcb5e..d0f9d6f 100644 --- a/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml +++ b/src/CalculateurMoyanne/CalculateurApp/View/BlockView.xaml @@ -14,7 +14,7 @@ ColumnSpacing="4"> diff --git a/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs b/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs index f19946c..cd5e734 100644 --- a/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs +++ b/src/CalculateurMoyanne/CalculateurApp/ViewModel/MaquetteViewModel.cs @@ -15,133 +15,138 @@ using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; -namespace CalculateurApp.ViewModel +namespace CalculateurApp.ViewModel; + +public partial class MaquetteViewModel:ObservableObject { - public partial class MaquetteViewModel:ObservableObject + + public BlocModel blocModel { get; set; } + // public ReadOnlyObservableCollectionlst { get; set; } + public Manager manager { get; set; } + + + public MaquetteViewModel() { + //Items = new ObservableCollection(); + + //try + //{ + // foreach (var BB in manager.GetAllBloc().Result) + // Items.Add(BB); + //} + //catch (Exception ex) + //{ + // Debug.WriteLine(ex); + //} - public BlocModel blocModel { get; set; } - // public ReadOnlyObservableCollectionlst { get; set; } - public Manager manager { get; set; } + //blocModel = new BlocModel(); + } + public void init1() + { + Items = new ObservableCollection(); - public MaquetteViewModel() + try { - //Items = new ObservableCollection(); - - //try - //{ - // foreach (var BB in manager.GetAllBloc().Result) - // Items.Add(BB); - //} - //catch (Exception ex) - //{ - // Debug.WriteLine(ex); - //} - - - //blocModel = new BlocModel(); + foreach (var BB in manager.GetAllBloc().Result) + Items.Add(BB); } - public void init1() + catch (Exception ex) { - Items = new ObservableCollection(); + Debug.WriteLine(ex); + } - try - { - foreach (var BB in manager.GetAllBloc().Result) - Items.Add(BB); - } - catch (Exception ex) - { - Debug.WriteLine(ex); - } + blocModel = new BlocModel(); + } + [ObservableProperty] + ObservableCollection items; + [ObservableProperty] + ObservableCollection lstblc=new ObservableCollection(); + [ObservableProperty] + string nom; + +[RelayCommand] + async void Add() + { + // Manager blocDbDataManager = new Manager(new BlocDbDataManager()); + + if (string.IsNullOrEmpty(blocModel.Nom)) + return; + //BlocModel u = blocModel; + //MaquetteModel u = new MaquetteModel(); + Items.Add(blocModel); + await manager.AddBlocmaquette(manager.SelectedMaquetteModel, blocModel); - blocModel = new BlocModel(); + } + [RelayCommand] + async void Delete(BlocModel bl) + + { + if (Items.Contains(bl)) + { + Items.Remove(bl); + await manager.DeleteBloc(bl); + var o = await manager.GetAllBloc(); } - [ObservableProperty] - ObservableCollection items; - [ObservableProperty] - ObservableCollection lstblc=new ObservableCollection(); - [ObservableProperty] - string nom; - [RelayCommand] - async void Add() - { - // Manager blocDbDataManager = new Manager(new BlocDbDataManager()); - - if (string.IsNullOrEmpty(blocModel.Nom)) - return; - //BlocModel u = blocModel; - //MaquetteModel u = new MaquetteModel(); - Items.Add(blocModel); - await manager.AddBlocmaquette(manager.SelectedMaquetteModel, blocModel); + + //if (Items.Contains(model)) + //{ + // Items.Remove(model); + // await manager.Deletemqt(model); - } - [RelayCommand] - async void Delete(BlocModel bl) - - { - if (Items.Contains(bl)) - { - Items.Remove(bl); - await manager.DeleteBloc(bl); - var o = await manager.GetAllBloc(); - } - - - //if (Items.Contains(model)) - //{ - // Items.Remove(model); - // await manager.Deletemqt(model); - - // var v = await manager.GetAllMaquette(); - // Console.WriteLine(v); - - //} - } - - [RelayCommand] - void AjoutUE(BlocModel bl) + // var v = await manager.GetAllMaquette(); + // Console.WriteLine(v); + //} + } + + [RelayCommand] + void AjoutUE(BlocModel bl) + + { + if (Items.Contains(bl)) { - if (Items.Contains(bl)) - { - Items.Remove(bl); - } + Items.Remove(bl); } + } - [RelayCommand] - async Task Tap(String s) - { - await Shell.Current.GoToAsync($"{nameof(UE)}?Nom={s}"); + [RelayCommand] + async Task Tap(String s) + { + await Shell.Current.GoToAsync($"{nameof(UE)}?Nom={s}"); - } - [RelayCommand] - async Task GoBack() - { - await Shell.Current.GoToAsync(".."); - } + } + [RelayCommand] + async Task GoBack() + { + await Shell.Current.GoToAsync(".."); + } - public void ApplyQueryAttributes(IDictionary query) - { - var Maquette = query["maquette"] as MaquetteModel; + public void ApplyQueryAttributes(IDictionary query) + { + var Maquette = query["maquette"] as MaquetteModel; - blocModel.IDMaquetteFrk = Maquette.Id; - } - [RelayCommand] - public void GetAllBloc() - { + blocModel.IDMaquetteFrk = Maquette.Id; + } + [RelayCommand] + public void GetAllBloc() + { - var result = manager.GetAllBloc(); - foreach(var item in result.Result) - { - lstblc.Add(item); + var result = manager.GetAllBloc(); + foreach(var item in result.Result) + { + lstblc.Add(item); - } } } + + [RelayCommand] + public void Blocview(IEnumerable blocModels) + { + //items.Add + } } diff --git a/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs index 83c16c0..d444526 100644 --- a/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs +++ b/src/CalculateurMoyanne/CalculateurMapping/BlocDbDataManager.cs @@ -57,6 +57,16 @@ namespace CalculateurMapping } return true; } + public async TaskGetByMaquette(MaquetteModel maquette) { + + + using (var context = new TContext()) + { + // + } + return true; + } + public async Task> GetAll() { //getAll diff --git a/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs b/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs index 6f4f347..cbfb3cf 100644 --- a/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs +++ b/src/CalculateurMoyanne/CalculateurMapping/MaquetteDbDataManager.cs @@ -51,6 +51,7 @@ namespace CalculateurMapping BlocEntity entity = new BlocEntity { Id = blocModel.Id, + Nom = blocModel.Nom, MaquetteEntity = new MaquetteEntity { Id = mqt.Id, @@ -62,10 +63,11 @@ namespace CalculateurMapping if (!data.Bloc.Contains(entity)) { data.Bloc.Add(entity); - await context.Bloc.AddAsync(entity); - // context.Maquettes.Update(data); - - await context.SaveChangesAsync(); + // await context.Maquettes.AddAsync(data); + // Console.WriteLine("jyij"); + context.Maquettes.Update(data); + + result = await context.SaveChangesAsync() > 0; } } //context.Database.EnsureCreated();