|
@@ -50,6 +50,9 @@ namespace Acosta.ViewModels
|
|
|
VisitsViewModel visitsVM = new VisitsViewModel(myConnection4);
|
|
|
public VisitsViewModel VisitsVM { get => visitsVM; set => visitsVM = value; }
|
|
|
|
|
|
+ UserViewModel userVM = new UserViewModel(myConnection);
|
|
|
+ public UserViewModel UserVM { get => userVM; set => userVM = value; }
|
|
|
+
|
|
|
public void SaveNetwork()
|
|
|
{
|
|
|
myConnection2.SaveChanges();
|
|
@@ -74,38 +77,14 @@ namespace Acosta.ViewModels
|
|
|
UC = new VisitsView();
|
|
|
}
|
|
|
|
|
|
- public void SaveEditUser()
|
|
|
- {
|
|
|
- myConnection5.SaveChanges();
|
|
|
- UC = new EmployeesView();
|
|
|
- }
|
|
|
-
|
|
|
- public void SaveEditOutlet()
|
|
|
- {
|
|
|
- myConnection6.SaveChanges();
|
|
|
- UC = new OutletsView();
|
|
|
- }
|
|
|
-
|
|
|
- public void EditUser(int userId)
|
|
|
- {
|
|
|
- editUserVM = new EditEmployeeViewModel(myConnection5, userId);
|
|
|
- UC = new EditEmployeesView();
|
|
|
- }
|
|
|
-
|
|
|
- public void EditOutlet(int outletId)
|
|
|
- {
|
|
|
- editOutletVM = new EditOutletViewModel(myConnection6, outletId);
|
|
|
- UC = new EditOutletsView();
|
|
|
- }
|
|
|
-
|
|
|
public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); }
|
|
|
private UserControl uc = new AuthorizationView();
|
|
|
public int curUsId;
|
|
|
-
|
|
|
+ Employee? currentUser;
|
|
|
public void LoadPersonalAccount()
|
|
|
{
|
|
|
-
|
|
|
- Employee? currentUser = myConnection.Employees.FirstOrDefault(x => x.Email == AuthorizationVM.Login && x.Password == AuthorizationVM.Password);
|
|
|
+
|
|
|
+ currentUser = myConnection.Employees.FirstOrDefault(x => x.Email == AuthorizationVM.Login && x.Password == AuthorizationVM.Password);
|
|
|
if (currentUser == null)
|
|
|
{
|
|
|
AuthorizationVM.Message = "Пользователя с такими данными не существует.";
|
|
@@ -120,16 +99,24 @@ namespace Acosta.ViewModels
|
|
|
curUsId = currentUser.Employeesid;
|
|
|
PersonalAccountVM = new PersonalAccountViewModel(myConnection, curUsId);
|
|
|
UC = new PersonalAccountView();
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void SavePassword()
|
|
|
+ {
|
|
|
+ ChangePasswordView changePasswordView = new ChangePasswordView();
|
|
|
+ currentUser = myConnection.Employees.FirstOrDefault(x => x.Email == AuthorizationVM.Login && x.Password == AuthorizationVM.Password);
|
|
|
+ changePasswordView.cp(currentUser);
|
|
|
+ myConnection.SaveChanges();
|
|
|
+ UC = new PersonalAccountView();
|
|
|
+ }
|
|
|
+
|
|
|
public List<Project> ListProjects => myConnection.Projects.ToList();
|
|
|
public List<TradeNetwork> ListTrades => myConnection.TradeNetworks.ToList();
|
|
|
public List<Employee> ListEmployees => myConnection.Employees.Include(x => x.RoleNavigation).ToList().Where(x => x.Employeesid != curUsId).ToList();
|
|
|
public List<Outlet> ListOutlets => myConnection.Outlets.ToList();
|
|
|
public List<Visit> ListVisits => myConnection.Visits.ToList();
|
|
|
-
|
|
|
-
|
|
|
//List<a> newList = new List<a>(new a((from p in myConnection.Outlets.ToList() select p.Outletid).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Address).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Location).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.TradeNetworks.ToList() select p.Title).ToImmutableList().ToList().FirstOrDefault()));
|
|
|
//public List<string> fkTrade => myConnection.TradeNetworks.ToList().Select(x => x.Title).Where()
|
|
|
//List<a> newList = new List<a>(new a((from p in myConnection.Outlets.ToList() select p.Outletid).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Address).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Location).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.TradeNetworks.ToList() select p.Title).ToImmutableList().ToList().FirstOrDefault()));
|
|
@@ -173,6 +160,13 @@ namespace Acosta.ViewModels
|
|
|
// })
|
|
|
//.ToList();
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/*public List<Role> rolesList => (from p in myConnection.Roles.ToList() where p.Title != "Оператор" select p).ToImmutableList().ToList();
|
|
|
public List<Employee> userList => (from p in myConnection.Employees.ToList() where p.Role != 1 select p).ToImmutableList().ToList();*/
|
|
|
|
|
@@ -184,7 +178,7 @@ namespace Acosta.ViewModels
|
|
|
{
|
|
|
UC = new VisitsView();
|
|
|
}
|
|
|
- public void EditVisitView()
|
|
|
+ public void EditVisitView(int userID)
|
|
|
{
|
|
|
UC = new EditVisitView();
|
|
|
}
|
|
@@ -197,7 +191,7 @@ namespace Acosta.ViewModels
|
|
|
{
|
|
|
UC = new ProjectsView();
|
|
|
}
|
|
|
- public void EditProjectsView()
|
|
|
+ public void EditProjectsView(int userID)
|
|
|
{
|
|
|
UC = new EditProjectsView();
|
|
|
}
|