public static void AddModes(this IModeRepository modeRepository, int entryCount, string plant) { for (var i = 0; i < entryCount; i++) { var mode = new Mode(plant, $"Mode-{i}", false); modeRepository.Add(mode); } }
public async Task <Result <int> > Handle(CreateModeCommand request, CancellationToken cancellationToken) { var newMode = new Mode(_plantProvider.Plant, request.Title, request.ForSupplier); _modeRepository.Add(newMode); await _unitOfWork.SaveChangesAsync(cancellationToken); return(new SuccessResult <int>(newMode.Id)); }
private async Task CloneModes(string sourcePlant, string targetPlant) { var originalPlant = _plantProvider.Plant; _plantSetter.SetPlant(sourcePlant); var sourceModes = await _modeRepository.GetAllAsync(); _plantSetter.SetPlant(originalPlant); var targetModes = await _modeRepository.GetAllAsync(); foreach (var sourceMode in sourceModes) { if (targetModes.SingleOrDefault(t => t.Title == sourceMode.Title) == null) { var targetMode = new Mode(targetPlant, sourceMode.Title, sourceMode.ForSupplier); _modeRepository.Add(targetMode); } } }