diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs')
2 files changed, 4 insertions, 53 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs index 8a33f15ef..652ad3093 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs @@ -17,10 +17,6 @@ using Microsoft.Win32; using Tango.Core.Helpers; using System.IO; using Tango.MachineStudio.Catalogs.Excel; -using Tango.BL.ActionLogs; -using Tango.MachineStudio.Common.Authentication; -using Tango.BL.Enumerations; -using Tango.BL.DTO; namespace Tango.MachineStudio.Catalogs.ViewModels { @@ -29,9 +25,6 @@ namespace Tango.MachineStudio.Catalogs.ViewModels private ObservablesContext _catalogsContext; private ObservablesContext _activeCatalogContext; private INotificationProvider _notification; - private IActionLogManager _actionLogManager; - private IAuthenticationProvider _authentication; - private ColorCatalogDTO _catalogBeforeSave; #region Properties @@ -158,11 +151,9 @@ namespace Tango.MachineStudio.Catalogs.ViewModels /// Initializes a new instance of the <see cref="MainViewVM"/> class. /// </summary> /// <param name="notificationProvider">The notification provider.</param> - public MainViewVM(INotificationProvider notificationProvider, IActionLogManager actionLogManager, IAuthenticationProvider authenticationProvider) : this() + public MainViewVM(INotificationProvider notificationProvider) : this() { - _actionLogManager = actionLogManager; _notification = notificationProvider; - _authentication = authenticationProvider; } #endregion @@ -206,7 +197,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels _activeCatalogContext = ObservablesContext.CreateDefault(); - ActiveCatalog = await new CatalogBuilder(_activeCatalogContext).Set(SelectedCatalog.Guid).WithGroups().WithItems().WithRecipes().BuildAsync(); + ActiveCatalog = await new ColorCatalogBuilder(_activeCatalogContext).Set(SelectedCatalog.Guid).WithGroups().WithItems().WithRecipes().BuildAsync(); SelectedGroup = ActiveCatalog.ColorCatalogsGroups.FirstOrDefault(); RMLS = await _activeCatalogContext.Rmls.ToListAsync(); @@ -215,8 +206,6 @@ namespace Tango.MachineStudio.Catalogs.ViewModels SelectedItem = SelectedGroup.ColorCatalogsItems.FirstOrDefault(); } - _catalogBeforeSave = ColorCatalogDTO.FromObservable(ActiveCatalog); - View.NavigateTo(CatalogsNavigationView.CatalogView); } catch (Exception ex) @@ -244,7 +233,6 @@ namespace Tango.MachineStudio.Catalogs.ViewModels { IsFree = false; await SelectedCatalog.DeleteCascadeAsync(_catalogsContext); - _actionLogManager.InsertLog(ActionLogType.CatalogDeleted, _authentication.CurrentUser, SelectedCatalog.Name, SelectedCatalog, "Catalog deleted using Machine Studio.", false); SelectedCatalog = null; } catch (Exception ex) @@ -277,7 +265,6 @@ namespace Tango.MachineStudio.Catalogs.ViewModels newCatalog.Company = "Twine"; _catalogsContext.ColorCatalogs.Add(newCatalog); await _catalogsContext.SaveChangesAsync(); - _actionLogManager.InsertLog(ActionLogType.CatalogCreated, _authentication.CurrentUser, newCatalog.Name, newCatalog, "Catalog created using Machine Studio."); SelectedCatalog = newCatalog; EditSelectedCatalog(); } @@ -318,44 +305,8 @@ namespace Tango.MachineStudio.Catalogs.ViewModels try { IsFree = false; - - //Validate color codes. - var duplicateCodes = ActiveCatalog - .ColorCatalogsGroups - .SelectMany(x => x.ColorCatalogsItems) - .GroupBy(x => x.Code) - .Where(x => x.Count() > 1) - .Select(x => x.First().Code) - .ToList(); - - if (duplicateCodes.Count > 0) - { - throw new InvalidOperationException($"Duplicate color codes found:\n{String.Join(Environment.NewLine, duplicateCodes)}"); - } - - //Validate color names. - var duplicateNames = ActiveCatalog - .ColorCatalogsGroups - .SelectMany(x => x.ColorCatalogsItems) - .GroupBy(x => x.Name) - .Where(x => x.Count() > 1) - .Select(x => x.First().Name) - .ToList(); - - if (duplicateNames.Count > 0) - { - throw new InvalidOperationException($"Duplicate color names found:\n{String.Join(Environment.NewLine, duplicateNames)}"); - } - - ActiveCatalog.LastUpdated = DateTime.UtcNow; await _activeCatalogContext.SaveChangesAsync(); - - var activeCatalogDTO = ColorCatalogDTO.FromObservable(ActiveCatalog); - _actionLogManager.InsertLog(ActionLogType.CatalogSaved, _authentication.CurrentUser, _catalogBeforeSave.Name, _catalogBeforeSave, activeCatalogDTO, "Catalog saved using Machine Studio."); - _catalogBeforeSave = activeCatalogDTO; - await LoadCatalogs(); - _notification.ShowInfo("Catalog updated successfully."); } catch (Exception ex) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml index 5a49c93d3..ded1acb2d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml @@ -13,7 +13,7 @@ xmlns:global="clr-namespace:Tango.MachineStudio.Catalogs" xmlns:local="clr-namespace:Tango.MachineStudio.Catalogs.Views" mc:Ignorable="d" - d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Foreground="{StaticResource DarkGrayBrush200}" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Foreground="#232323" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <UserControl.Resources> <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> @@ -51,7 +51,7 @@ <Grid DockPanel.Dock="Top"> <StackPanel Orientation="Horizontal"> <Button Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" Command="{Binding BackToCatalogsCommand}"> - <materialDesign:PackIcon Kind="ArrowLeft" Width="50" Height="50" Foreground="{StaticResource DarkGrayBrush200}" ToolTip="Back to RML list" /> + <materialDesign:PackIcon Kind="ArrowLeft" Width="50" Height="50" Foreground="#202020" ToolTip="Back to RML list" /> </Button> <TextBlock Text="{Binding ActiveCatalog.Name}" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="34"></TextBlock> </StackPanel> |
