From 2b7e5ddfd169892d60f73944443bfbfcf6a5a001 Mon Sep 17 00:00:00 2001 From: dyakonovr Date: Fri, 3 May 2024 19:31:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/MessageInfoStorage.cs | 80 +++++++++---------- .../Implements/ImplementerStorage.cs | 38 ++++----- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/MessageInfoStorage.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/MessageInfoStorage.cs index 13027ce..e0f634f 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/MessageInfoStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/MessageInfoStorage.cs @@ -11,47 +11,47 @@ using System.Threading.Tasks; namespace SoftwareInstallationFileImplement.Implements { - public class MessageInfoStorage : IMessageInfoStorage - { - private readonly DataFileSingleton source; - public MessageInfoStorage() - { - source = DataFileSingleton.GetInstance(); - } - public MessageInfoViewModel GetElement(MessageInfoSearchModel model) - { - if (model.MessageId == null) - return null; - return source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel; - } + public class MessageInfoStorage : IMessageInfoStorage + { + private readonly DataFileSingleton source; + public MessageInfoStorage() + { + source = DataFileSingleton.GetInstance(); + } + public MessageInfoViewModel? GetElement(MessageInfoSearchModel model) + { + if (model.MessageId == null) + return null; + return source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel; + } - public List GetFilteredList(MessageInfoSearchModel model) - { - if (!model.ClientId.HasValue) - return new(); - return source.Messages - .Where(x => x.ClientId == model.ClientId) - .Select(x => x.GetViewModel) - .ToList(); - } + public List GetFilteredList(MessageInfoSearchModel model) + { + if (!model.ClientId.HasValue) + return new(); + return source.Messages + .Where(x => x.ClientId == model.ClientId) + .Select(x => x.GetViewModel) + .ToList(); + } - public List GetFullList() - { - return source.Messages - .Select(x => x.GetViewModel) - .ToList(); - } + public List GetFullList() + { + return source.Messages + .Select(x => x.GetViewModel) + .ToList(); + } - public MessageInfoViewModel Insert(MessageInfoBindingModel model) - { - var newMessage = Message.Create(model); - if (newMessage == null) - { - return null; - } - source.Messages.Add(newMessage); - source.SaveMessages(); - return newMessage.GetViewModel; - } - } + public MessageInfoViewModel? Insert(MessageInfoBindingModel model) + { + var newMessage = Message.Create(model); + if (newMessage == null) + { + return null; + } + source.Messages.Add(newMessage); + source.SaveMessages(); + return newMessage.GetViewModel; + } + } } diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ImplementerStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ImplementerStorage.cs index 1d93ef5..3c69863 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ImplementerStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ImplementerStorage.cs @@ -2,6 +2,7 @@ using SoftwareInstallationContracts.SearchModels; using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationContracts.ViewModels; +using SoftwareInstallationListImplement.Models; using System; using System.Collections.Generic; using System.Linq; @@ -92,29 +93,28 @@ namespace SoftwareInstallationListImplement.Implements return result; } - public ImplementerViewModel? Insert(ImplementerBindingModel model) - { - model.Id = 1; + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = 1; - foreach (var implementer in _source.Implementers) - { - if (model.Id <= implementer.Id) - { - model.Id = implementer.Id + 1; - } - } + foreach (var implementer in _source.Implementers) + { + if (model.Id <= implementer.Id) + { + model.Id = implementer.Id + 1; + } + } - return null; - /*var res = Implementer.Create(model);*/ + var res = Implementer.Create(model); - /*if (res != null) - { - _source.Implementers.Add(res); - } - return res?.GetViewModel;*/ - } + if (res != null) + { + _source.Implementers.Add(res); + } + return res?.GetViewModel; + } - public ImplementerViewModel? Update(ImplementerBindingModel model) + public ImplementerViewModel? Update(ImplementerBindingModel model) { foreach (var implementer in _source.Implementers) {