public SQLQueryResult <EmergencyAgreement> Add(MasterDataInfoViewModel masterDataInfoVM) { emergencyAgreementSelected.ReadOnly = false; SQLQueryResult <EmergencyAgreement> result = null; if (EmergencyAgreementSelected.Id > 0) { //TODO update Kaleder event missing result = MySQLDataAccess.UpdateEmergencyAgreement(EmergencyAgreementSelected); } else { if (EmergencyAgreementSelected.NotificationTime > 0) { EmergencyAgreementSelected.GoogleCalendarEventId = AddGooleEvent(masterDataInfoVM); } EmergencyAgreementSelected.CustomerId = masterDataInfoVM.MachineInformationSelected.CustomerId; EmergencyAgreementSelected.LocationId = masterDataInfoVM.MachineInformationSelected.Id; EmergencyAgreementSelected.MachineInformationId = masterDataInfoVM.MachineInformationSelected.Id; result = MySQLDataAccess.AddEmergencyAgreement(EmergencyAgreementSelected); } LoadComboboxes(); return(result); }
public void ReleaseEditing() { Task.Factory.StartNew(() => { MySQLDataAccess.ReleaseEditingEmergencyAgreement(EmergencyAgreementSelected.Id); }); }
public SQLQueryResult <MaintenanceAgreement> Add(MasterDataInfoViewModel masterDataInfoVM, MaintenanceAgreementContentViewModel maintenanceAgreementContentVM) { maintenanceAgreementSelected.ReadOnly = false; SQLQueryResult <MaintenanceAgreement> result = null; if (MaintenanceAgreementSelected.Id > 0) { result = MySQLDataAccess.UpdateMaintenanceAgreement(MaintenanceAgreementSelected, maintenanceAgreementContentVM.MaintenanceAgreementContents.ToList()); } else { if (MaintenanceAgreementSelected.NotificationTime > 0) { MaintenanceAgreementSelected.GoogleCalendarEventId = AddGooleEvent(masterDataInfoVM); } MaintenanceAgreementSelected.CustomerId = masterDataInfoVM.MachineInformationSelected.CustomerId; MaintenanceAgreementSelected.LocationId = masterDataInfoVM.MachineInformationSelected.Id; MaintenanceAgreementSelected.MachineInformationId = masterDataInfoVM.MachineInformationSelected.Id; result = MySQLDataAccess.AddMaintenanceAgreement(MaintenanceAgreementSelected, maintenanceAgreementContentVM.MaintenanceAgreementContents.ToList()); } LoadComboboxes(); return(result); }
public void ReleaseEditing() { Task.Factory.StartNew(() => { MySQLDataAccess.ReleaseEditingCustomer(CustomerSelected.Id); }); }
public void ReleaseEditing() { Task.Factory.StartNew(() => { MySQLDataAccess.ReleaseEditingLocation(LocationSelected.Id); }); }
public void ReleaseEditing() { Task.Factory.StartNew(() => { MySQLDataAccess.ReleaseEditingRecord(RecordSelected.Id); }); }
public void ReleaseEditing() { Task.Factory.StartNew(() => { MySQLDataAccess.ReleaseEditingMachineInformation(MachineInformationSelected.Id); }); }
private ObservableCollection <RecordAgreementType> GetAgreementType() { if (machineInformationSelected == null || machineInformationSelected.Id < 0) { return(new ObservableCollection <RecordAgreementType>()); } var maintenanceAgreements = MySQLDataAccess.GetMaintenanceAgreements(machineInformationSelected.Id).OrderByDescending(c => c.AgreementDate); List <RecordAgreementType> agreements = new List <RecordAgreementType>(); foreach (var maintenanceAgreement in maintenanceAgreements) { agreements.Add(new RecordAgreementType { AgreementType = Helper.Helper.TTypeMangement.MaintenanceAgreement, MaintenanceAgreement = maintenanceAgreement }); } var ergencyAgreements = MySQLDataAccess.GetEmergencyAgreementsByMachineInformation(machineInformationSelected.Id).OrderByDescending(c => c.AgreementDate); foreach (var ergencyAgreement in ergencyAgreements) { agreements.Add(new RecordAgreementType { AgreementType = Helper.Helper.TTypeMangement.EmergencyAgreement, EmergencyAgreement = ergencyAgreement }); } return(new ObservableCollection <RecordAgreementType>(agreements)); }
public void ReleaseEditing() { Task.Factory.StartNew(() => { MySQLDataAccess.ReleaseEditingMaintenanceAgreement(MaintenanceAgreementSelected.Id); }); }
public void AddOtherInformations(MachineInformation machineInformation) { if (otherInformations.Count <= 0 || machineInformation == null && machineInformation.Id < 0) { return; } MySQLDataAccess.AddOtherInformations(machineInformation, OtherInformations.ToList(), OtherInformationDeleted); OtherInformationDeleted = new List <OtherInformation>(); }
public SQLQueryResult <Customer> EditCustomer() { var result = MySQLDataAccess.GetCustomerForEdit(CustomerSelected.Id); if (!result.IsReadOnly) { CustomerSelected = result.DBRecords.FirstOrDefault() as Customer; } return(result); }
public SQLQueryResult <MaintenanceAgreement> EditMaintenanceAgreement() { var result = MySQLDataAccess.GetMaintenanceAgreementForEdit(MaintenanceAgreementSelected.Id); if (!result.IsReadOnly) { MaintenanceAgreementSelected = result.DBRecords.FirstOrDefault() as MaintenanceAgreement; } return(result); }
public SQLQueryResult <Record> EditRecord() { var result = MySQLDataAccess.GetRecordForEdit(RecordSelected.Id); if (!result.IsReadOnly) { RecordSelected = result.DBRecords.FirstOrDefault() as Record; } return(result); }
public void RefreshMachine(MachineInformation machineInformation) { if (machineInformation == null) { return; } RecordsMa = MySQLDataAccess.GetRecords(machineInformation.Id); FillCombobox(); }
public SQLQueryResult <EmergencyAgreement> EditEmergencyAgreement() { var result = MySQLDataAccess.GetEmergencyAgreementForEdit(EmergencyAgreementSelected.Id); if (!result.IsReadOnly) { EmergencyAgreementSelected = result.DBRecords.FirstOrDefault() as EmergencyAgreement; } return(result); }
public SQLQueryResult <MachineInformation> EditMachineInformation() { var result = MySQLDataAccess.GetMachineInformationForEdit(MachineInformationSelected.Id); if (!result.IsReadOnly) { MachineInformationSelected = result.DBRecords.FirstOrDefault() as MachineInformation; } return(result); }
public SQLQueryResult <Location> EditLocation() { var result = MySQLDataAccess.GetLocationForEdit(LocationSelected.Id); if (!result.IsReadOnly) { LocationSelected = result.DBRecords.FirstOrDefault() as Location; } return(result); }
public void Refresh(MachineInformation machineInformation) { if (machineInformation == null) { return; } // Records = TestData.GetRecords(); Records = new ObservableCollection <Record>(MySQLDataAccess.GetRecords(machineInformation.Id)); }
public SQLQueryResult <Customer> Add() { customerSelected.ReadOnly = false; if (CustomerSelected.Id > 0) { return(MySQLDataAccess.UpdateCustomer(CustomerSelected)); } else { return(MySQLDataAccess.AddCustomer(CustomerSelected)); } }
public SQLQueryResult <Location> Add(Customer customer) { locationSelected.ReleaseRow(); if (locationSelected.Id > 0) { return(MySQLDataAccess.UpdateLocation(locationSelected)); } else { locationSelected.CustomerId = customer.Id; return(MySQLDataAccess.AddLocation(locationSelected)); } }
public SQLQueryResult <MachineInformation> Add(Location location) { machineInformationSelected.ReadOnly = false; if (MachineInformationSelected.Id > 0) { return(MySQLDataAccess.UpdateMachineInformation(MachineInformationSelected)); } else { MachineInformationSelected.CustomerId = location.CustomerId; MachineInformationSelected.LocationId = location.Id; return(MySQLDataAccess.AddMachineInformation(MachineInformationSelected)); } }
public SQLQueryResult <Record> Add() { RecordSelected.ReadOnly = false; if (RecordSelected.Id > 0) { return(MySQLDataAccess.UpdateRecord(RecordSelected)); } else { RecordSelected.CustomerId = machineInformationSelected.CustomerId; RecordSelected.LocationId = machineInformationSelected.LocationId; RecordSelected.MachineInformationId = machineInformationSelected.Id; return(MySQLDataAccess.AddRecord(RecordSelected)); } }
public void ShouldThrowAnExceptionWhenFailingToConnectToMySQLDatabase() { //Create a failing mock Mock <IDbConnection> connectionMock = new Mock <IDbConnection>(); connectionMock.Setup(x => x.Open()).Throws(new Exception("Unable to connect to the MySQL database instance for some reason")); string sql = "SELECT * FROM users;"; MySQLDataAccess dataAccess = new MySQLDataAccess(testConnectionString, connectionMock.Object); Action failAction = () => dataAccess.ExecuteDataTable(sql); failAction.Should() .Throw <Exception>() .WithMessage("Connection to the database was not possible. See inner exception for information."); }
private void RefreshMachineInformation() { if (locationSelected == null || locationSelected.Id == machineInformationSelected.LocationId) { return; } machineInformations.Clear(); if (locationSelected.Id < -1) { MachineInformations = machineInformations.AddRange(MySQLDataAccess.GetMachineInformations()); } else { MachineInformations = machineInformations.AddRange(MySQLDataAccess.GetMachineInformations(locationSelected)); } }
public void Refresh() { var customerTask = Task.Factory.StartNew(() => { Customers = new ObservableCollection <Customer>(MySQLDataAccess.GetCustomers()); }); var locationTask = Task.Factory.StartNew(() => { Locations = new ObservableCollection <Location>(MySQLDataAccess.GetLocations()); }); var machineInfomationTask = Task.Factory.StartNew(() => { MachineInformations = new ObservableCollection <MachineInformation>(MySQLDataAccess.GetMachineInformations()); }); // maintenanceAgreements = TestData.GetMaintenanceAgreements(); // Task.Factory.StartNew(() => RefreshOtherInformations()); Task.Factory.StartNew(() => RefreshMaintenanceAgreements()); }
public void RefreshLocation() { if (customerSelected == null || customerSelected.Id == locationSelected.CustomerId) { return; } locations.Clear(); if (MangementType != Helper.Helper.TTypeMangement.MachineInformation) { locations.Add(Location.GetDummy()); } if (customerSelected.Id < -1) { Locations = locations.AddRange(MySQLDataAccess.GetLocations()); } else { Locations = locations.AddRange(MySQLDataAccess.GetLocations(CustomerSelected)); } }
public void Refresh() { MachineInformations = MySQLDataAccess.GetMachineInformations(); }
public void RefreshByLocation(long id) { MachineInformations = MySQLDataAccess.GetMachineInformationsByLocation(id); }
public void Refresh(long maintenanceAgreementId) { if (maintenanceAgreementId < 0) { List <MaintenanceAgreementContent> dd = new List <MaintenanceAgreementContent>(); dd.Add(new MaintenanceAgreementContent { Content = "Inhalt 1", Provide = "Nein" }); dd.Add(new MaintenanceAgreementContent { Content = "Inhalt 2", Provide = "Ja" }); MaintenanceAgreementContents = new ObservableCollection <MaintenanceAgreementContent>(dd); return; } MaintenanceAgreementContents = new ObservableCollection <MaintenanceAgreementContent>(MySQLDataAccess.GetMaintenanceAgreementContents(maintenanceAgreementId)); }
public void RefreshOnlyCustomers() { Customers = MySQLDataAccess.GetCustomersOnly(); }