private void OnAdd() { user = Serializer.DeserializeUser(); int count = 0; int number = -1; CurrentPicture = new Picture(uri, Title, Description); CurrentPicture.Validate(); if (CurrentPicture.IsValid) { user.Pictures.Add(new Picture(uri, Title, Description)); PictureViewModel.picturesChange(user); allUsers = Serializer.Deserialize(); foreach (Users tempuser in allUsers.Users) { if (tempuser.Username == user.Username) { number = count; } count++; } allUsers.Users[number].Pictures.Add(CurrentPicture); Serializer.SerializeUser(allUsers.Users[number]); Serializer.Serialize(allUsers); Title = ""; Description = ""; Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\pc\Desktop\Blok5-Projekat1\MVVM1\bin\Debug\addLogo.png", true); ButtonSource = BitmapConversion.BitmapToBitmapSource(bitmap); } }
public void Login() { bool valid = false; currentUsers = Serializer.Deserialize(); foreach (Users user in currentUsers.Users) { if (CurrentUser.Username == user.Username && CurrentUser.Password == user.Password) { curUserLog = user; } } CurrentUser.ValidateLogin(currentUsers); if (CurrentUser.IsValid) { MenuViewModel.mode = "l"; Application.Current.MainWindow.Content = new MenuViewModel(); //MenuViewModel.current = curUserLog; Serializer.SerializeUser(curUserLog); PictureViewModel.picturesChange(curUserLog); } }