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) {