TaskDoerUserControlViewModel.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using WpfApp29.Models;
  6. namespace WpfApp29.ViewModels
  7. {
  8. class TaskDoerUserControlViewModel : BaseTaskUserControlViewModel
  9. {
  10. public TaskDoerUserControlViewModel() { }
  11. public TaskDoerUserControlViewModel(Task task) : base(task) { }
  12. public RelayCommand? _commandDeclineTask;
  13. public RelayCommand? CommandDeclineTask
  14. {
  15. get
  16. {
  17. return _commandDeclineTask ??= new RelayCommand(
  18. x =>
  19. {
  20. MainContext ctx = new MainContext();
  21. ctx.Tasks.ToList().First(t => Task.Id == t.Id).StatusId = 1;
  22. ctx.SaveChanges();
  23. });
  24. }
  25. }
  26. public RelayCommand? _commandDoneTask;
  27. public RelayCommand? CommandDoneTask
  28. {
  29. get
  30. {
  31. return _commandDoneTask ??= new RelayCommand(
  32. x =>
  33. {
  34. MainContext ctx = new MainContext();
  35. ctx.Tasks.ToList().First(t => Task.Id == t.Id).StatusId = 3;
  36. ctx.SaveChanges();
  37. });
  38. }
  39. }
  40. }
  41. }