public void GetAll() { ReceivedThermostats.Clear(); foreach (var item in context.GetAll()) { ReceivedThermostats.Add(item); } }
public void Spend() { var spendedThermostat = new SpendedThermostat { ThermostatId = SelectedReceivedThermostat.ThermostatId, ReceivedDate = SelectedReceivedThermostat.ReceivedDate, ActivityPerformed = SelectedReceivedThermostat.ActivityPerformed, RepairDate = RepairDate, DescriptionIntervention = SelectedReceivedThermostat.DescriptionIntervention, LastLocation = SelectedReceivedThermostat.LastLocation, ReceivingEmployee = SelectedReceivedThermostat.ReceivingEmployee, SpendingEmployee = String.Format("{0} {1}", EmployeeViewModel.SelectedEmployee.FirstName, EmployeeViewModel.SelectedEmployee.LastName) }; context.SetLastPreventionDate(SelectedReceivedThermostat); context.SetLastWashDate(SelectedReceivedThermostat); context.SetCurrentLocation(SelectedReceivedThermostat, CurrentLocation); context.SetCurrentStatus(SelectedReceivedThermostat, "Sprawny"); if (CurrentLocation != "Warsztat") //If the release on the machine it seems { context.Spend(spendedThermostat); if (SelectedReceivedThermostat != null) { context.Remove(SelectedReceivedThermostat); ReceivedThermostats.Remove(SelectedReceivedThermostat); SelectedReceivedThermostat = null; } } else //If the relese for the workshop take back { var receivedThermostat = new ReceivedThermostat { ThermostatId = SelectedReceivedThermostat.ThermostatId, ReceivedDate = SelectedReceivedThermostat.ReceivedDate, ActivityPerformed = "Do wydania", DescriptionIntervention = null, LastLocation = SelectedReceivedThermostat.LastLocation, ReceivingEmployee = SelectedReceivedThermostat.ReceivingEmployee }; context.UpdateOnSpend(receivedThermostat); context.Spend(spendedThermostat); } ConnectedSuccessfully = true; }