private void SavePlan(object scratchObject) { if (scratchObject is ScratchViewModel scratch) { scratch.Plan.IsScratch = false; _dbContext.DailyPlans.SaveItem(scratch.Plan); scratch.Tasks.ForEach(t => { t.Task.PlanId = scratch.Plan.Id; _dbContext.Tasks.SaveItem(t.Task); }); if (_currentWeekViewModel.Plans.All(p => p.Plan.Id != scratch.Plan.Id)) { var viewModel = new DailyPlanViewModel(_dbContext, scratch.Plan, _currentWeekViewModel); _currentWeekViewModel.Plans.Add(viewModel); } if (Scratches.Contains(scratch)) { Scratches.Remove(scratch); } } Back(); }
private void SaveScratch(object scratchObject) { if (scratchObject is ScratchViewModel scratch) { var id = _dbContext.DailyPlans.SaveItem(scratch.Plan); if (!Scratches.Contains(scratch)) { Scratches.Add(scratch); } scratch.Tasks.ForEach(t => { t.Task.PlanId = id; _dbContext.Tasks.SaveItem(t.Task); }); } Back(); }