private async Task JoinProject() { if (mAlertItem.Alert.ProjectId != null) { mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); var reponse = await mApiService.JoinProject(mAlertItem.Alert.ProjectId.Value, mAlertItem.Alert.Id); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (reponse.StatusCode == System.Net.HttpStatusCode.OK) { mCacheService.AlertItems.Remove(mAlertItem); Close(this); ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Reload, ViewModelType = typeof(HomeViewModel), SubViewModelType = typeof(ProjectsViewModel) }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); } } }
private void Close() { //ShowViewModel<MainViewModel>(); ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Reload, ViewModelType = typeof(ProfileViewModel), Data = "COMPLETED_PROFILE" }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); Close(this); }
protected override async Task <List <ViewModelAction> > CreateActionsAsync() { var actions = await base.CreateActionsAsync(); var indexOfCreate = actions.IndexOf(actions.Single(a => a.Name == DisplayActions.Create.Key)); actions[indexOfCreate] = new ViewModelAction(DisplayActions.CatchEmAll_UpdateFromSource) { Color = ViewModelActionColor.Primary }; actions.Add(new ViewModelAction(DisplayActions.CatchEmAll_EditQuery)); actions.Add(new ViewModelAction(DisplayActions.CatchEmAll_ShowArchive)); return(actions); }
protected override async Task <List <ViewModelAction> > CreateActionsAsync() { var actions = await base.CreateActionsAsync(); using (var context = this.dataAccess.GetContext()) { if ((await context.NoTracking <DAL.Entities.Category>().BelongingToCurrentUser().CountAsync()) == 0) { var create = actions.Single(a => a.Name == nameof(DisplayActions.Create)); var indexOfCreate = actions.IndexOf(create); actions[indexOfCreate] = new ViewModelAction(DisplayActions.CatchEmAll_ImportExisting) { Color = ViewModelActionColor.Primary }; create.Color = ViewModelActionColor.Secondary; actions.Add(create); } } return(actions); }
private void Save() { mCacheService.TempDescription = Description; ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Reload, ViewModelType = typeof(CreateProjectViewModel), Data = Description }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); ViewModelAction action1 = new ViewModelAction { ActionType = ViewModelActionType.Reload, ViewModelType = typeof(EditProjectViewModel), Data = Description }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action1)); Close(this); }
private async Task DeleteProject() { mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); var succeed = await mApiService.DeleteProject(mProjectItem.Id.Value); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (succeed) { ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Remove, ViewModelType = typeof(HomeViewModel), SubViewModelType = typeof(ProjectsViewModel), Data = mProjectItem.Id }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); BackToViewModel <MainViewModel>(); } }
private async void Save() { try { CertValidator validatorWorkCompenstation = new CertValidator(); var result3 = validatorWorkCompenstation.Validate(CompensationCert); if (!result3.IsValid) { var firstError = result3.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } CertValidator validatorPublicLiability = new CertValidator(); var result = validatorPublicLiability.Validate(PublicLiabilityCert); if (!result.IsValid) { var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } CertValidator validatorProductLiability = new CertValidator(); var result1 = validatorProductLiability.Validate(ProductLiabilityCert); if (!result1.IsValid) { var firstError = result1.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } for (int j = 0; j < LicenceCerts.Count; j++) { CertValidator validatorLicences2 = new CertValidator(); var result2 = validatorLicences2.Validate(LicenceCerts[j]); if (!result2.IsValid) { var firstError = result2.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } } if (IsCheckVerify == false) { mMessageboxService.ShowToast("Please verify this is information is true "); View.ScrollToBottom(); return; } if (IsTickPublicLiability != true) { PublicLiabilityCert.CertItem.Amount = null; PublicLiabilityCert.CertItem.Document = null; PublicLiabilityCert.CertItem.Expiry = null; } if (IsTickProductLiability != true) { ProductLiabilityCert.CertItem.Amount = null; ProductLiabilityCert.CertItem.Document = null; ProductLiabilityCert.CertItem.Expiry = null; } if (IsTickCompensation != true) { CompensationCert.CertItem.Document = null; CompensationCert.CertItem.Expiry = null; } mCompanyProfile.Certs[0] = CompensationCert.CertItem; mCompanyProfile.Certs[1] = PublicLiabilityCert.CertItem; mCompanyProfile.Certs[2] = ProductLiabilityCert.CertItem; mCompanyProfile.Certs[3] = GSTRegisteredCert.CertItem; for (int i = 0; i < LicenceCerts.Count; i++) { mCompanyProfile.Certs.Add(LicenceCerts[i].CertItem); } mCompanyProfile.ProfileCompletionStep = ProfileCompletionStep.CPComplete; mCompanyProfile.StatementAgree = DateTime.Now; mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); while (!Mvx.Resolve <ITaskManagementService>().IsAllTaskDone()) { int numOfImages = Mvx.Resolve <ITaskManagementService>().NumberOfTasksRunning(); if (numOfImages > 0) { string uploadStr = numOfImages + (numOfImages > 1 ? " images " : " image ") + "processing"; mProgressDialogService.ShowProgressDialog(uploadStr); } else { mProgressDialogService.ShowProgressDialog(""); } await Task.Delay(150); } var response = await mApiService.CreateCompanyProfile(mCompanyProfile); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { mCacheService.IsShowProfileView = true; mMessageboxService.ShowToast("Company Profile Complete"); Mvx.Resolve <ITrackingService>().SendEvent("Company Profile completed"); ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Reload, ViewModelType = typeof(ProfileViewModel), Data = "COMPLETED_PROFILE" }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); BackToViewModel <MainViewModel>(); } else { RefreshListLicences(); if (!string.IsNullOrEmpty(response.ErrorData)) { string errorData = response.ErrorData; ErrorLoginResponse err = JsonConvert.DeserializeObject <ErrorLoginResponse>(errorData); mMessageboxService.ShowToast(err.Description); } } } catch (Exception ex) { RefreshListLicences(); mMessageboxService.Show("Error", ex.Message); } }
private async Task SaveProject() { View.HidenKeyboard(); if (EmailInvite != string.Empty) { Invite(); } if (Title == null || Title == "") { mMessageboxService.ShowToast(Messages.EmptyProjectName); return; } if (string.IsNullOrEmpty(mCacheService.TempDescription)) { mMessageboxService.ShowToast(Messages.EmptyDescriptionProjectName); return; } else { Description = mPlatformService.GetPreference("Description"); //mPlatformService.SetPreference("Description", ""); } var inviteData = new List <Invite>(); for (int i = 0; i < Invites.Count; i++) { inviteData.Add(Invites[i].Invite); } Project project = new Project() { UserId = Mvx.Resolve <ICacheService>().CurrentUserData.UserId, Title = Title, Description = mCacheService.TempDescription, Stage = Stage, Created = DateTime.Now, Started = DateTime.Now, Updated = DateTime.Now, Invites = inviteData }; mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); var response = await mApiService.CreateProject(project); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var data = response.Data; mMessageboxService.ShowToast("Add project successful"); Mvx.Resolve <ITrackingService>().SendEvent("Created Project"); mPlatformService.SetPreference("Description", String.Empty); var newProject = new ProjectHeading { ProjectId = (long)data.Id, Stage = data.Stage, Title = data.Title, UserIsCreator = true, CreatedJoined = (System.DateTimeOffset)data.Created, Alert = false, }; ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Add, ViewModelType = typeof(HomeViewModel), SubViewModelType = typeof(ProjectsViewModel), Data = newProject }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); Close(this); } else { string errorData = response.ErrorData; if (!string.IsNullOrEmpty(errorData)) { mMessageboxService.ShowToast(errorData); } } }
private async Task SaveAndUpdate() { View.HideKeyboard(); ProjectValidator validator = new ProjectValidator(); var project = new Project { Title = Title, Description = Description, Stage = Stage, Invites = mProjectItem.Invites, Id = mProjectItem.Id, UserId = mProjectItem.UserId, Owner = mProjectItem.Owner, Active = true }; var result = validator.Validate(project); if (result.IsValid) { mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); var succeed = await mApiService.UpdateProject(project); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (succeed) { mMessageboxService.ShowToast("Saved!"); mCacheService.ProjectHeadingItem.ProjectHeading.Title = Title; mCacheService.ProjectHeadingItem.RaisePropertyChanged("ProjectHeading"); // update the view project ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Update, ViewModelType = typeof(ViewProjectViewModel), Data = project }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); // update the project tabs ViewModelAction action2 = new ViewModelAction { ActionType = ViewModelActionType.Update, ViewModelType = typeof(HomeViewModel), SubViewModelType = typeof(ProjectsViewModel), Data = project }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action2)); Close(this); } } else if (result.Errors != null) { var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); } }