public async Task <IActionResult> LogIn(UserResources user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var myUser = await manager.FindByEmailAsync(user.Email); if (myUser == null) { return(BadRequest(ModelState)); } var result = await signInManager.CheckPasswordSignInAsync(myUser, user.Password, lockoutOnFailure : false); if (!result.Succeeded) { return(BadRequest("The entries did'nt match any of our records")); } myUser.LastActivity = DateTime.Now; await signInManager.SignInAsync(myUser, false); var finalResult = mapper.Map <AppUser, UserResources>(myUser); return(Ok(finalResult)); }
public async Task <UserResources> GetUserResources(UserDB pUser) { if (DatosFirebaseRTHelper.Instance.isInit == false) { return(null); } UserResources userResources = new UserResources(); DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.UsersResourcesTable) .Child(pUser.Name.ToLower()).KeepSynced(true); await DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.UsersResourcesTable) .Child(pUser.Name.ToLower()) .Child(resources).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { //Debug.Log("NoChild"); // Handle the error... userResources = null; } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; userResources = JsonUtility.FromJson <UserResources>(snapshot.GetRawJsonValue()); } }); return(userResources); }
public async Task <IActionResult> GetUsers(string filter = null, int?startIndex = null, int?count = null, string sortBy = null) { UserResources objUsers = null; try { objUsers = await graphService.GetUsers(filter, startIndex, count, sortBy); return(Ok(objUsers)); } catch (NotFoundException ex) { Log.Warning(ex, "Users not found."); return(StatusCode(StatusCodes.Status204NoContent)); } catch (BadRequestException ex) { Log.Warning(ex.Message); return(BadRequest()); } catch (Exception ex) { Log.Error("Exception occurred while handling a GetUsers message.", ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <UserResources> LoadUserResourcesFromFirebase(UserDB pUser) { UserResources userResources = await fbUserResources.GetUserResources(pUser); resources = userResources; return(userResources); }
private void load(GameHost host, VignetteConfigManager config, UserResources userResources, ThemeManager manager) { theme = manager.Current.GetBoundCopy(); AddRange(new Drawable[] { new SettingsDropdown <Theme> { Label = "Theme", Current = theme, ItemSource = manager.UseableThemes, }, new SettingsButton { Label = "Open themes folder", Action = () => userResources.Themes.OpenInNativeExplorer(), }, new SettingsButton { Label = "Theme Designer", Description = "Opens Microsoft's Fluent Theme Designer in a browser. Export the theme as JSON and save it in your themes folder.", Action = () => host.OpenUrlExternally("https://aka.ms/themedesigner"), }, }); }
public async Task <IActionResult> Register([FromForm] UserResources user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newUser = mapper.Map <UserResources, AppUser>(user); newUser.UserName = user.Name; var result = await manager.CreateAsync(newUser, user.Password); if (!result.Succeeded) { return(BadRequest(result.Errors)); } await SetRole(newUser); await unit.Commit(); await signInManager.SignInAsync(newUser, isPersistent : false); newUser.LastActivity = DateTime.Now; var token = GenerateJwtToken(newUser.Email, newUser); return(Ok(token)); }
protected override async void OnAppearing() { var ur = new UserResources(); var user = await ur.GetUserAsync(); UserNameLabel.Text = user.Name; }
public void SaveUserResources(UserResources userResources) { _userResources = userResources; string json = JsonConvert.SerializeObject(userResources); using StreamWriter writer = new StreamWriter(Constants.PATH_USER_RESOURCES); writer.Write(json); writer.Close(); }
public async Task <IActionResult> PutUser([FromBody] UserResources u) { var user = mapper.Map <UserResources, Users>(u); context.Users.Add(user); await context.SaveChangesAsync(); return(Ok(u)); }
public void LoadUserResourcesFromFirebase(UserResources userResources) { if (userResources != null) { Money = userResources.Gold; StartCoroutine(GivePacks(userResources.UnopendPacks, true)); if (debugOn) { Debug.Log("USER RESOURCES LOADED FROM DB ONLINE"); } } }
public async void CreateNewUserResources(UserDB user) { UserResources userResources = await GetStartingResources(); if (userResources != null) { string json = JsonUtility.ToJson(userResources); await DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.UsersResourcesTable) .Child(user.Name.ToLower()) .Child(resources).SetRawJsonValueAsync(json); } }
public async Task FilterNameStartsWithUsers() { UserResources expected = Helper.CreateUserResources(); User expectedUser = expected.resources.Where(x => x.id == "8c09a9d1-f1a2-463b-bd0f-b10c51c437d0").SingleOrDefault(); HttpResponseMessage response = await Startup.Client.GetAsync("directory/users?filter=startswith(givenName,'S')"); Assert.IsTrue(response.IsSuccessStatusCode); var res = response.Content.ReadAsStringAsync().Result; var userRes = JsonConvert.DeserializeObject <UserResources>(res); User resultUser = userRes.resources.Where(x => x.id == "8c09a9d1-f1a2-463b-bd0f-b10c51c437d0").SingleOrDefault(); resultUser.Should().BeEquivalentTo(expectedUser); }
public HttpResponseMessage Resources() { HttpResponseMessage response = null; Domain.UserResources mUserResources = new UserResources(); try { mUserResources = userService.GetResources(); response = Request.CreateResponse(HttpStatusCode.OK, mUserResources); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } return(response); }
private void OnTriggerEnter(Collider other) { UserResources.CollectCoin(); GetComponent <MeshRenderer>().enabled = false; GetComponent <SphereCollider>().enabled = false; AudioManager.PlaySFX(AudioResources.Instance.collect_coin); //Destroy(gameObject, particles.main.duration); particles.Play(); particles.transform.SetParent(transform.parent); // Starts a couroutine using the GameManager MonoBehaviour Coroutine coroutine = GameManager.Get().StartCoroutine(DestroyParticle(particles.main.duration)); // Destroy the pickup object Destroy(gameObject); }
public async Task <int> GetUserUnopenPacksAmount(UserDB pUserDB) { if (DatosFirebaseRTHelper.Instance.isInit == false) { return(0); } FbUserResources fbUserResources = new FbUserResources(); UserResources userResources = await fbUserResources.GetUserResources(pUserDB); if (userResources != null) { return(userResources.UnopendPacks); } else { return(0); } }
private void LoadUserResources() { if (!File.Exists(Constants.PATH_USER_RESOURCES)) { using FileStream tmp = File.Create(Constants.PATH_USER_RESOURCES); tmp.Close(); SaveUserResources(new UserResources()); return; } string json = File.ReadAllText(Constants.PATH_USER_RESOURCES); _userResources = JsonConvert.DeserializeObject <UserResources>(json); if (_userResources == null) { _userResources = new UserResources(); SaveUserResources(_userResources); } }
private async void SetUser(UserDB pUser) { //UserDB fuser = new UserDB("mmm", "", "", "", "", false); userManager.SetUser(pUser); if (pUser.IsFirstTime == true) { cardCollectionManager.CreateNewUserCollections(pUser); userResourcesManager.CreateNewUserResources(pUser); } cardCollectionManager.LoadCollections(pUser); cardLimitDataManager.LoadCardLimitData(pUser); GamePricesData priceData = await LoadPriceDataFromFirebase(); UserResources userResources = await LoadUserResourcesFromFirebase(); shopManager.LoadPriceDataFromFirebase(priceData); shopManager.LoadUserResourcesFromFirebase(userResources); }
public static UserResources CreateUserResources() { List <User> users = new List <User>() { new User() { id = "12502bbc-5e91-4e08-8de6-2f4163c127d7", givenName = "Chaitanya", surname = "Sonavale", email = null, userPrincipalName = "chaitanya.sonavale_synerzip.com#EXT#@synerzipindia.onmicrosoft.com" }, new User() { id = "7887e707-587f-44a7-98a9-002a0ad55580", givenName = "Pallavi", surname = "Jadhav", email = null, userPrincipalName = "*****@*****.**" }, new User() { id = "8c09a9d1-f1a2-463b-bd0f-b10c51c437d0", givenName = "Saket", surname = "Adhav", email = null, userPrincipalName = "*****@*****.**" } }; UserResources expected = new UserResources(); expected.resources = users; return(expected); }
public async Task <UserResources> GetUsers(string filter, int?startIndex, int?count, string sortBy) { try { UserResources users = new UserResources(); users.resources = new List <Models.User>(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load users profiles. var userList = await client.Users.Request().Filter($"{filter}").GetAsync(); // Copy Microsoft User to DTO User foreach (var user in userList) { var objUser = CopyHandler.UserProperty(user); users.resources.Add(objUser); } users.totalResults = users.resources.Count; return(users); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { Log.Warning(ex.Message); throw new BadRequestException(); } else if (ex.StatusCode == HttpStatusCode.NotFound) { Log.Warning(ex.Message); throw new NotFoundException(); } else { throw new Exception(); } } }
public ThemeManager(Scheduler scheduler, UserResources resources, VignetteConfigManager config) { this.scheduler = scheduler; UseableThemes.Add(Theme.Light); UseableThemes.Add(Theme.Dark); store = resources.Themes; store.FileCreated += onFileCreated; store.FileDeleted += onFileDeleted; store.FileUpdated += onFileUpdated; store.FileRenamed += onFileRenamed; loadExistingThemes(); themeConfig = config.GetBindable <string>(VignetteSetting.Theme); themeConfig.BindValueChanged(e => { if (e.NewValue == Current.Value.Name) { return; } Current.Value = UseableThemes.FirstOrDefault(t => t.Name == e.NewValue) ?? Theme.Light; SourceChanged?.Invoke(); }, true); Current.BindValueChanged(e => { if (themeConfig.Value == e.NewValue.Name) { return; } themeConfig.Value = e.NewValue.Name; SourceChanged?.Invoke(); }, true); }
protected override async void OnAppearing() { var ur = new UserResources(); var user = await ur.GetUserAsync(); EmailLabel.Text = user.Email; ProviderLabel.Text = user.IdentityProvider; UserLabel.Text = user.Name; st = new StateActionResources(); var text = await st.GetStateAction(); if (string.IsNullOrWhiteSpace(text)) { StateGrid.IsVisible = false; } else { StateGrid.IsVisible = true; StateLabel.Text = text; } }
public void ValidUsers() { var expected = new UserResources(); expected.resources = new List <User>() { new User() { id = "1", email = "*****@*****.**", givenName = "abc", surname = "abc", userPrincipalName = "abc" }, new User() { id = "2", email = "*****@*****.**", givenName = "abc", surname = "abc", userPrincipalName = "abc" } }; Mock <IGraphService> v = new Mock <IGraphService>(); v.Setup(k => k.GetUsers(It.IsAny <string>(), It.IsAny <int?>(), It.IsAny <int?>(), It.IsAny <string>())).ReturnsAsync(expected); DirectoryController cn = new DirectoryController(v.Object); OkObjectResult response = cn.GetUsers(null).Result as OkObjectResult; expected.Should().BeEquivalentTo(response.Value); }
private async Task <UserResources> LoadUserResourcesFromFirebase() { UserResources userResources = await userResourcesManager.LoadUserResourcesFromFirebase(GetUser()); return(userResources); }
private void load() { Resources.AddStore(new DllResourceStore(VignetteResources.ResourceAssembly)); AddFont(Resources, @"Fonts/SegoeUI"); AddFont(Resources, @"Fonts/SegoeUI-Italic"); AddFont(Resources, @"Fonts/SegoeUI-Bold"); AddFont(Resources, @"Fonts/SegoeUI-BoldItalic"); AddFont(Resources, @"Fonts/SegoeUI-Black"); AddFont(Resources, @"Fonts/SegoeUI-BlackItalic"); AddFont(Resources, @"Fonts/SegoeUI-Light"); AddFont(Resources, @"Fonts/SegoeUI-LightItalic"); AddFont(Resources, @"Fonts/SegoeUI-SemiBold"); AddFont(Resources, @"Fonts/SegoeUI-SemiBoldItalic"); AddFont(Resources, @"Fonts/SegoeUI-SemiLight"); AddFont(Resources, @"Fonts/SegoeUI-SemiLightItalic"); AddFont(Resources, @"Fonts/Spartan-Bold"); AddFont(Resources, @"Fonts/FluentSystemIcons-Filled"); AddFont(Resources, @"Fonts/Vignette"); dependencies.CacheAs(this); dependencies.CacheAs(LocalConfig); UserResources = new UserResources(Host, Storage); dependencies.CacheAs(UserResources); var themeManager = new ThemeManager(Scheduler, UserResources, LocalConfig); dependencies.CacheAs(themeManager); dependencies.CacheAs <IThemeSource>(themeManager); showFps = LocalConfig.GetBindable <bool>(VignetteSetting.ShowFpsOverlay); showFps.BindValueChanged(e => FrameStatistics.Value = e.NewValue ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None, true); resizable = LocalConfig.GetBindable <bool>(VignetteSetting.WindowResizable); base.Content.Add(new SafeAreaContainer { RelativeSizeAxes = Axes.Both, Child = new DrawSizePreservingFillContainer { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { new FluentContextMenuContainer { RelativeSizeAxes = Axes.Both, Child = new FluentTooltipContainer { RelativeSizeAxes = Axes.Both, Child = content = new Container { RelativeSizeAxes = Axes.Both }, }, }, new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both, } }, }, }); }
public UserResources GetResources() { UserResources mUserResourcesList = new UserResources(); mUserResourcesList.maritalStatuses = Enum.GetValues(typeof(MaritalStatus)) .Cast <MaritalStatus>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.bloodTypes = Enum.GetValues(typeof(BloodType)) .Cast <BloodType>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.documentTypes = Enum.GetValues(typeof(DocumentType)) .Cast <DocumentType>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.educationalAttainments = Enum.GetValues(typeof(EducationalAttainment)) .Cast <EducationalAttainment>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.homeMaterials = Enum.GetValues(typeof(HomeMaterial)) .Cast <HomeMaterial>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.homeOwnerships = Enum.GetValues(typeof(HomeOwnership)) .Cast <HomeOwnership>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.homeTypes = Enum.GetValues(typeof(HomeType)) .Cast <HomeType>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.physicalActivities = Enum.GetValues(typeof(PhysicalActivity)) .Cast <PhysicalActivity>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.sexes = Enum.GetValues(typeof(Sex)) .Cast <Sex>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.departments = departmentRepository.GetAllDepartment().Select(x => new Domain.ObjectNode() { id = x.id.ToString().ToUpper(), name = x.name }).ToList(); mUserResourcesList.countries = countryRepository.GetAllCountry().Select(x => new Domain.ObjectNode() { id = x.id.ToString().ToUpper(), name = x.name }).ToList(); mUserResourcesList.medicines = Enum.GetValues(typeof(Medicine)) .Cast <Medicine>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.backgrounds = Enum.GetValues(typeof(Background)) .Cast <Background>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString().Replace('_', ' ')) }) .ToList(); mUserResourcesList.allergies = Enum.GetValues(typeof(Allergy)) .Cast <Allergy>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.alcoholConsumptions = Enum.GetValues(typeof(Alcohol)) .Cast <Alcohol>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.fvConsumptions = Enum.GetValues(typeof(FruitsVegetables)) .Cast <FruitsVegetables>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.races = Enum.GetValues(typeof(Race)) .Cast <FruitsVegetables>() .Select(d => new ObjectNode() { id = d.ToString().ToUpper(), name = StringExtensions.FirstCharToUpper(d.ToString()) }) .ToList(); mUserResourcesList.provinces = provinceRepository.GetAllProvince().Select(x => new Domain.ObjectNode() { id = x.id.ToString().ToUpper(), name = x.name }).ToList(); mUserResourcesList.districts = districtRepository.GetAllDistrict().Select(x => new Domain.ObjectNode() { id = x.id.ToString().ToUpper(), name = x.name }).ToList(); return(mUserResourcesList); }