public async void Initialize() { var dbtask = DBController.GetAssetInfo(AssetID); InitializeComponent(); CurrentInfo = await dbtask; asset_sn_label.Text = CurrentInfo.AssetSN; asset_name_label.Text = CurrentInfo.AssetName; department_label.Text = CurrentInfo.Department; priority_combo.DataSource = CurrentInfo.Priorities; }
public static async Task <AssetEMPageInfo> GetAssetInfo(int assetID) { //get information on the asset from database using (var db = new Session2Entities()) { AssetEMPageInfo AssetPage = new AssetEMPageInfo(); var priorities = (from p in db.Priorities select p.Name).ToList(); var asset = (from e in db.EmergencyMaintenances where e.ID == assetID select e).First(); AssetPage.AssetSN = asset.Asset.AssetSN; AssetPage.AssetID = (int)asset.AssetID; AssetPage.AssetName = asset.Asset.AssetName; AssetPage.Department = asset.Asset.DepartmentLocation.Department.Name; AssetPage.Priorities = priorities; return(AssetPage); } }
public static async Task addEmergencyMaintenance(AssetEMPageInfo info) { //insert maintenance request using (var db = new Session2Entities()) { var ID = (from em in db.EmergencyMaintenances orderby em.ID descending select em.ID).First() + 1; var priorityID = (from p in db.Priorities where p.Name == info.SelectedPriorities select p.ID).First(); EmergencyMaintenance EM = new EmergencyMaintenance(); EM.ID = ID; EM.PriorityID = priorityID; EM.AssetID = info.AssetID; EM.DescriptionEmergency = info.Description; EM.OtherConsiderations = info.Considerations; EM.EMTechnicianNote = null; EM.EMReportDate = DateTime.Now; EM.EMStartDate = DateTime.Now; db.EmergencyMaintenances.Add(EM); await db.SaveChangesAsync(); } }