コード例 #1
0
 public static List<string> GetTypeIDModelList()
 {
     List<string> listOfTypes = new List<string>();
     using (var db = new RepairCenterModelFirstContainer())
     {
         foreach (var type in db.UnitTypes)
         {
             string thisType = type.TypeID + " " + type.Model;
             listOfTypes.Add(thisType);
         }
     }
     return listOfTypes;
 }
コード例 #2
0
 public static List<string> GetTechnicianIDAliasList()
 {
     List<string> listOfTech = new List<string>();
     using (var db = new RepairCenterModelFirstContainer())
     {
         foreach (var technician in db.Technicians)
         {
             string thisTech = technician.TechID + " " + technician.Alias;
             listOfTech.Add(thisTech);
         }
     }
     return listOfTech;
 }
コード例 #3
0
        public static bool TryCreateUnitType(string model, string description)
        {
            bool isCreated = false;
            if (model == "" || description == "") return isCreated;
            using (var db = new RepairCenterModelFirstContainer())
            {
                UnitType newType = new UnitType() { Model = model, Description = description };
                db.UnitTypes.Add(newType);
                db.SaveChanges();
                isCreated = true;
            }

            return isCreated;
        }
コード例 #4
0
        public static bool TryCreateTechnician(string alias, string fullName, string telNumber)
        {
            bool isCreated = false;
            if (alias == "" || fullName == "" || telNumber == "") return isCreated;
            using (var db = new RepairCenterModelFirstContainer())
            {
                Technician newTech = new Technician() { Alias = alias, FullName = fullName, TelephoneNumber = telNumber, Status = TechnicianStatus.Free };
                db.Technicians.Add(newTech);
                db.SaveChanges();
                isCreated = true;
                //\(?\d{3}\)?-? *\d{3}-? *-?\d{4}
            }

            return isCreated;
        }
コード例 #5
0
 public static ObservableCollection<UnitTypeViewModel> GetUnitTypeCollection()
 {
     ObservableCollection<UnitTypeViewModel> typeList = new ObservableCollection<UnitTypeViewModel>();
     using (var db = new RepairCenterModelFirstContainer())
     {
         var typeQuery = from a in db.UnitTypes
             select new UnitTypeViewModel
             {
                 TypeID = a.TypeID,
                 Model = a.Model,
                 Description = a.Description
             };
         typeList = new ObservableCollection<UnitTypeViewModel>(typeQuery);
     }
     return typeList;
 }
コード例 #6
0
 public static ObservableCollection<TechnicianViewModel> GetTechnicianViewModelCollection()
 {
     ObservableCollection<TechnicianViewModel> techList = new ObservableCollection<TechnicianViewModel>();
     using (var db = new RepairCenterModelFirstContainer())
     {
         var techQuery = from a in db.Technicians
             select new TechnicianViewModel
             {
                 TechID = a.TechID,
                 Alias = a.Alias,
                 FullName = a.FullName,
                 Status = a.Status,
                 TelephoneNumber = a.TelephoneNumber
             };
         techList = new ObservableCollection<TechnicianViewModel>(techQuery);
     }
     return techList;
 }
コード例 #7
0
 public static bool TryDeleteUnitType(UnitTypeViewModel thisModel)
 {
     bool deleteSuccess = false;
     if (thisModel == null) return deleteSuccess;
     using (var db = new RepairCenterModelFirstContainer())
     {
         var activitiesQuery = db.Activities.FirstOrDefault(x => x.UnitTypeTypeID == thisModel.TypeID);
         if (activitiesQuery == null)
         {
             var trueType = db.UnitTypes.FirstOrDefault(z => z.TypeID == thisModel.TypeID);
             db.UnitTypes.Remove(trueType);
             db.SaveChanges();
             deleteSuccess = true;
         }
         else
         {
             System.Windows.MessageBox.Show("Type could not be removed. Activities of that type exist.");
         }
     }
     return deleteSuccess;
 }
コード例 #8
0
 public static bool TryDeleteTechnician(TechnicianViewModel thisModel)
 {
     bool deleteSuccess = false;
     if (thisModel == null) return deleteSuccess;
     using (var db = new RepairCenterModelFirstContainer())
     {
         var techQuery = db.Technicians.FirstOrDefault(x => x.TechID == thisModel.TechID);
         if (techQuery != null)
         {
             if (techQuery.Status != TechnicianStatus.Busy)
             {
                 db.Technicians.Remove(techQuery);
                 db.SaveChanges();
                 deleteSuccess = true;
             }
             else
             {
                 System.Windows.MessageBox.Show("Technician is currently busy.");
             }
         }
     }
     return deleteSuccess;
 }