1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using ReactiveUI;
- using Tmds.DBus.Protocol;
- namespace FoodLogProject.ViewModels
- {
- public class Page6ViewModel : ReactiveObject
- {
- Customer? currentUser;
- GaruaevContext myConnection;
- string oldPassowrd;
- public Page6ViewModel(Customer? currentUser, GaruaevContext myConnection)
- {
- this.CurrentUser = currentUser;
- this.myConnection = myConnection;
- oldPassowrd = currentUser.CustomerPassword;
- }
- public Customer? CurrentUser { get => currentUser; set => currentUser = value; }
- public string Birthday { get => currentUser.CustomerBirthdate.ToString(); set => currentUser.CustomerBirthdate = Convert.ToDateTime(value); }
- public string ConfirmPassowrd { get => confirmPassowrd; set => confirmPassowrd = value; }
- public string Message { get => message; set => this.RaiseAndSetIfChanged(ref message, value); }
- public bool ChangePassword { get => changePassword; set => this.RaiseAndSetIfChanged(ref changePassword, value); }
- string confirmPassowrd;
- string message;
- bool changePassword;
- public void SaveData()
- {
- if (currentUser.CustomerPassword == null || currentUser.CustomerPassword == "") currentUser.CustomerPassword = oldPassowrd;
- if (ChangePassword == (currentUser.CustomerPassword == confirmPassowrd))
- {
- Message = "Ñîõðàíåíî óñïåøíî";
- myConnection.SaveChanges();
- }
- else
- {
- Message = "Ïàðîëè íå ñîâïàäàþò";
- }
- }
- }
- }
|