public static User GetUser(string email) { var user = DBInstance.FindUser(email); if (user == null) { return(null); } return(user); }
public static void CreateUser(string pass, string email) { var user = new User(); user.Email = email; user.Level = AccesLevel.Minimal; user.GetSalt(); user.EncryptedPassword = user.EncodePassword(pass); DBInstance.SaveUser(user); user.SendMail("You have registered with your " + email + " email address!", "Succesfully registration in the SmartHome system!"); }
public void ModifyPassword(string newPassword) { var user = DBInstance.FindUser(this.Email); if (user != null) { user.GetSalt(); string newEncryptedPassword = user.EncodePassword(newPassword); user.EncryptedPassword = newEncryptedPassword; } DBInstance.UpdateUser(user); }
public static void SetAccesLevel(string email, AccesLevel newLevel) { if (Level != AccesLevel.Admin) { return; } var user = DBInstance.FindUser(email); if (user != null) { user.Level = newLevel; } DBInstance.UpdateUser(user); }
public static List <User> GetAllUser() { var users = DBInstance.AvailableUser(); List <User> users2 = new List <User>(); foreach (var user in users) { if (user.Email != LoginedUser.Email) { users2.Add(user); } } return(users2); }
public void SaveUser() { DBInstance.SaveUser(this); }
private void Bt_Delete(object sender, RoutedEventArgs e) { DBInstance.RemoveUser(selectedUser); this.Frame.Navigate(typeof(SetAcces)); }
//Bejövő adatok szortírozása, a Process hívja meg private async static Task <string> SortString(string[] data) { string cmd = data[0]; if (cmd == "SND") { DataSample newel = new DataSample { SenderId = data[1], Temperature = double.Parse(data[6]), Humidity = double.Parse(data[5]), Movement = int.Parse(data[7]), CoLevel = double.Parse(data[3]), LpgLevel = double.Parse(data[2]), SmokeLevel = double.Parse(data[4]) }; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { AutoLightControl(newel); Collections.AddToActualDatas(newel); }); DBInstance.SaveData(newel); } if (cmd == "JND") { Unit newUnit = new Unit { Id = data[1], Type = data[2] }; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Collections.AddToNodeList(newUnit); }); } if (cmd == "REQIP") { Unit newUnit = new Unit { Type = data[1] }; newUnit.Id = GivenId.ToString(); GivenId += 10000000; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Collections.AddToNodeList(newUnit); }); } if (cmd == "SEL") { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (!Collections.UnitsToLocalize.Contains(data[1])) { Collections.UnitsToLocalize.Add(data[1]); } }); } return(cmd); }