public HomeViewModel(/*UserProfile userProfile*/ object owner) { dummyCmd = new DummyCommand(this); dummy2Cmd = new Dummy2Command(this); this.UserProfile = (UserProfile)owner; HomeUserControlViewModel = new HomeUserControlViewModel(this); UserProfileUserControlViewModel = new UserProfileUserControlViewModel(this); DashboardUserControlViewModel = new DashboardUserControlViewModel(this); HistoryUserControlViewModel = new HistoryUserControlViewModel(this); ContractorUserControlViewModel = new ContractorUserControlViewModel(this); homeUserControlViewModel.SubscribeMeToThis(this); userProfileUserControlViewModel.SubscribeMeToThis(this); dashboardUserControlViewModel.SubscribeMeToThis(this); historyUserControlViewModel.SubscribeMeToThis(this); contractorUserControlViewModel.SubscribeMeToThis(this); }
public JobRequestViewModel(object owner) { var guid = Guid.NewGuid().ToString().Replace("-", ""); mediaFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), guid + ".3gpp"); var parentViewModel = (HomeUserControlViewModel)owner; this.parentViewModel = parentViewModel; if (parentViewModel != null) { ContractorIcon = Helper.Utilities.GetIconByCategory(parentViewModel.CurrentSelectedCategory); JobRequestType = parentViewModel.CurrentSelectedCategory; UserProfile = parentViewModel.UserProfile; this.SubscribeMeToThis(parentViewModel); } jobService = new JobService(); locationService = new LocationService(); userProfileRepository = new UserProfileRepository(); PopulateLocations(); SetInitialTimes(); ContractorsAvailable = 0; //TODO: call api SearchLocationCmd = new SearchLocationCommand(this); SubmitJobRequestCmd = new SubmitJobCommand(this); ChangeProfileImageCmd = new Xamarin.Forms.Command(e => { ChangeProfileImageAsync(); }, (param) => { return(true); }); RecordVoiceCmd = new Xamarin.Forms.Command(e => { Navigator.Instance.OkAlert("Alert", "Begin recording your voice once you tapped OK, and tap on the solid rectangular icon on your right to stop", "OK", () => { //for android BeginRecording(); }, () => { //for ios BeginRecording(); }); }, param => { return(true); }); PlayRecordedCmd = new Xamarin.Forms.Command(e => { PlayRecordedVoice(); }, param => { return(true); }); StopCmd = new Xamarin.Forms.Command(e => { StopMedia(); }, param => { return(true); }); DeleteCmd = new Xamarin.Forms.Command(e => { Navigator.Instance.ConfirmationAlert("Alert", "Are you sure you want to delete your voice message?", "Yes", "No", () => { //for android RemoveRecordedVoice(); }, () => { //for ios RemoveRecordedVoice(); }); }, param => { return(true); }); LoadImageUploaderOptions(); InitializeVoiceButtons(); SetupMediaPlayer(); InitializeMinStartAndEndDates(); }