123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using FurnaceUI.Models;
- namespace FurnaceUI.Views.Recipes
- {
- public class RecipeStepDeleteDialogViewModel:FurnaceUIViewModelBase
- {
- public RecipeDataBase Recipe { get; set; }
- private ObservableCollection<Step> _newSteps = new ObservableCollection<Step>();
- public ObservableCollection<Step> NewSteps
- {
- get
- {
- if (Recipe != null && Recipe.Steps != null)
- {
- _newSteps.Clear();
- Recipe.Steps.Where(x => !x.Name.ToLower().Contains("standby") && !x.Name.ToLower().Contains("end")).ToList().ForEach(s => _newSteps.Add(s));
- return _newSteps;
- }
- else
- {
- return null;
- }
- }
- }
- public RecipeStepDeleteDialogViewModel(RecipeDataBase CurrentRecipe)
- {
- Recipe = CurrentRecipe;
- }
- public void DeleteSteps()
- {
- List<Step> test = new List<Step>();
-
- ObservableCollection<Step> TempSteps = Recipe.Steps;
- test = TempSteps.Where(x => x.IsChecked == true).ToList();
- foreach (var item in test)
- {
- Recipe.Steps.Remove(item);
- }
- Step step = Recipe.Steps.FirstOrDefault(x => x.Name == "Standby");
- for (int i = 0; i < Recipe.Steps.Count; i++)
- {
- if (step == null)
- {
- Recipe.Steps[i].StepNo = i + 1;
- }
- else
- {
- Recipe.Steps[i].StepNo = i;
- }
- }
- }
- }
- }
|