public static ProjectInsight.Models.Base.Responses.ApiSaveResponse SaveUser(ProjectInsight.Models.Users.User user) { try { //return client.GetMe(new ProjectInsight.Models.Base.ModelProperties("default,Name,EmailAddress,Address1,Address2,Phone,PhotoUrl,CellPhone,City,PostCode,Country,Region,Company,Department;Department:default")); return(client.Save(user)); } catch (Exception ex) { // AuthenticationService.Logout(); return(null); } }
private async void OnActivate(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCode.Text) || string.IsNullOrEmpty(txtCode.Text.Trim())) { Common.Instance.ShowToastMessage("Please provide correct activation code", DoubleResources.DangerSnackBar); return; } var activationCode = txtCode.Text.Trim(); ProjectInsightWebApiClient client = new ProjectInsightWebApiClient(Common.WorkspaceApi); try { DeviceActivationRequestComplete completeRequest = await client.DeviceActivationRequest.CompleteRequestAsync(DeviceActivationId, activationCode, "Chrome", null); if (completeRequest == null) { Common.Instance.ShowToastMessage("Please check the activation code or request new one", DoubleResources.DangerSnackBar); return; } string ApiToken = completeRequest.ApiToken; DateTime TokenExpirationDateTime = completeRequest.AuthenticationTokenExpirationDateTimeUTC.Value; string DeviceId = completeRequest.DeviceId; string UserId = completeRequest.UserId; if (AuthenticationService.PI_Client == null) { APIsInitialization.InitializeApis(ApiToken); Common.CurrentWorkspace.ApiToken = ApiToken; Common.CurrentWorkspace.UserID = new Guid(completeRequest.UserId); Common.Instance._sqlconnection.Update(Common.CurrentWorkspace); ProjectInsight.Models.Users.User userMe = UsersService.GetSimpleMe(); Common.UserGlobalCapability = userMe.UserGlobalCapability; Common.WorkspaceCapability = WorkspaceService.GetWorkspaceCapability(); //var logingUser = await UsersService.GetUser(new Guid(UserId)); //ProjectInsightMobile.Models.User user = new ProjectInsightMobile.Models.User(); //user.Email = logingUser.EmailAddress; //user.FirstName = logingUser.FirstName; //user.LastName = logingUser.LastName; //user.DateTimeCreated = DateTime.Now; //user.UserToken = ApiToken; //user.UserID = new Guid(UserId); //Common.Instance.user = user; //SQLiteConnection connection = Common.Instance.InitializeDatabase(); //Common.Instance.CreateTable<User>(); //Common.Instance._sqlconnection.Insert(user); } //Common.Instance.ShowToastMessage("Success", DoubleResources.SuccessSnackBar); //await Navigation.PushAsync(new StartupMasterPage()); App.Current.MainPage = new StartupMasterPage(); } catch (Exception ex) { } }
private async void GridTemplate_Tapped(object sender, EventArgs e) { //try //{ if (sender is SwipeGestureGrid || sender is Grid) { var templateGrid = (Grid)sender; if (templateGrid.Parent != null && templateGrid.Parent.BindingContext != null) { Workspace workspace = ((Workspace)templateGrid.Parent.BindingContext); if (workspace.Id >= 0) { var workspaces = Common.Instance.GetWorkspaces(); foreach (Workspace ws in workspaces.Where(x => x.isActive)) { ws.isActive = false; Common.Instance._sqlconnection.Update(ws); } workspace.isActive = true; Common.Instance._sqlconnection.Update(workspace); Common.CurrentWorkspace = workspace; if (string.IsNullOrEmpty(workspace.ApiToken) || workspace.UserID == null) { await Navigation.PushAsync(new SignIn(workspace)); } else { APIsInitialization.InitializeApis(); ProjectInsight.Models.Users.User userMe = UsersService.GetSimpleMe(); Common.UserGlobalCapability = userMe.UserGlobalCapability; Common.WorkspaceCapability = WorkspaceService.GetWorkspaceCapability(); Common.Instance.bottomNavigationViewModel.ActiveIcon = 1; string notifCount = string.Empty; //Common.Instance.bottomNavigationViewModel.IsNottificationContVisible = false; if (userMe.NotificationNewCount != null && userMe.NotificationNewCount.Value > 0) { // Common.Instance.bottomNavigationViewModel.IsNottificationContVisible = true; if (userMe.NotificationNewCount.Value > 99) { notifCount = "99+"; } else { notifCount = userMe.NotificationNewCount.Value.ToString(); } } Common.Instance.bottomNavigationViewModel.NumberNottificationItems = notifCount; Common.Instance.bottomNavigationViewModel.NumberWorkListItems = new ObservableCollection <MyWorkItem>(Common.Instance.GetUserWork().Where(x => x.ItemType != ItemType.Projects && x.WorkspaceId == Common.CurrentWorkspace.Id)).Count; Common.Instance.bottomNavigationViewModel.NumberProjectItems = new ObservableCollection <MyWorkItem>(Common.Instance.GetUserWork().Where(x => x.ItemType == ItemType.Projects && x.WorkspaceId == Common.CurrentWorkspace.Id)).Count; App.Current.MainPage = new StartupMasterPage(); } //var itemID = item.Id; } else if (workspace.Id == -1) { await Navigation.PushAsync(new SignInWorkSpace()); } else if (workspace.Id == -2) { if (Xamarin.Forms.Device.RuntimePlatform.ToLower() == "android") { await Navigation.PushAsync(new StartUp()); } else { await Navigation.PushAsync(new SignInWorkSpace()); } } } } //} //catch (Exception ex) //{ //} }