Advertisement
machtalDevWASD

My ViewModel

Dec 11th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.91 KB | None | 0 0
  1. namespace FiberStarMobileApp.Core.ViewModels.AttendanceViewModels
  2. {
  3.     public class ListDetailAttendanceViewModel : BaseViewModel
  4.     {
  5.         private readonly IAttendanceService _service;
  6.         private IMvxAsyncCommand _onCancelButtonCommand;
  7.  
  8.         public event PropertyChangedEventHandler PropertyChanged;
  9.  
  10.         HttpClient client = new HttpClient();
  11.         private long _idItem;
  12.         private MyModel _attend;
  13.         private ImageSource _imgSelfieDetail;
  14.         private bool _isLoadBusy = false;
  15.  
  16.         public ListDetailAttendanceViewModel(IMvxNavigationService navigationService, IAuthService authService, IAttendanceService service) : base(navigationService, authService)
  17.         {
  18.             _service = service;
  19.  
  20.             MessagingCenter.Unsubscribe<Pages.Attendance.ListAttendPage, long>(this, "OnItemSelected");
  21.             MessagingCenter.Subscribe<Pages.Attendance.ListAttendPage, long>(this, "OnItemSelected", async (sender, value) =>
  22.             {
  23.                 _idItem = value;
  24.                 await PerformShimmerAsyncTask(_idItem.ToString());
  25.             });
  26.         }
  27.  
  28.         public bool IsLoadBusy
  29.         {
  30.             get { return _isLoadBusy; }
  31.             set
  32.             {
  33.                 _isLoadBusy = value;
  34.                 OnPropertyChanged();
  35.             }
  36.         }
  37.  
  38.         public MyModel Attend
  39.         {
  40.             get { return _attend; }
  41.             set { SetProperty(ref _attend, value); }
  42.         }
  43.  
  44.         protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
  45.         {
  46.             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  47.         }
  48.  
  49.         public ImageSource ImgSelfieDetail
  50.         {
  51.             get { return _imgSelfieDetail; }
  52.             set { _imgSelfieDetail = value; RaisePropertyChanged(() => ImgSelfieDetail); }
  53.         }
  54.  
  55.         public IMvxAsyncCommand OnCancelButtonCommand => _onCancelButtonCommand ??
  56.             (_onCancelButtonCommand = new MvxAsyncCommand(OnCancelButton));
  57.  
  58.         private async Task OnCancelButton()
  59.         {
  60.             await NavigationService.Close(this);
  61.         }
  62.  
  63.         public async Task PerformShimmerAsyncTask(string id)
  64.         {
  65.             this.Attend = new MyModel
  66.             {
  67.                 //Image = null,
  68.                 AddressDetail = "x",
  69.                 Created = DateTime.Now,
  70.                 Activity = "x",
  71.                 Note = "x"
  72.             };
  73.            
  74.             this.IsLoadBusy = true;
  75.             await Task.Delay(2500);
  76.             this.IsLoadBusy = false;
  77.             //await GetItem(id);
  78.  
  79.             this.Attend = new MyModel
  80.             {
  81.                Image = "selfie.png",
  82.                AddressDetail = "asdasdasda",
  83.                Created = DateTime.Now,
  84.                Activity = "sadasdasdasfacf",
  85.                Note = "asuuusfasfa"
  86.             };
  87.         }
  88.     }
  89.  
  90.    
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement