コード例 #1
0
 public void Delete(TrainingDb trainingDb)
 {
     using (var context = new QualificationDbContext())
     {
         context.Entry(trainingDb).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #2
0
 public void Add(TrainingDb trainingDb)
 {
     using (var context = new QualificationDbContext())
     {
         context.Trainings.Add(trainingDb);
         context.SaveChanges();
     }
 }
コード例 #3
0
        private TrainingDb ToTrainingDb(Training training)
        {
            var trainingDb = new TrainingDb();

            trainingDb.Id          = training.ID;
            trainingDb.StaffDbId   = training.StaffID;
            trainingDb.TrainerId   = training.TrainerID;
            trainingDb.ProjectId   = training.ProjectID;
            trainingDb.ModelId     = training.ModelID;
            trainingDb.OperationId = training.OperationID;
            trainingDb.StartDate   = training.StartDate;
            trainingDb.EndDate     = training.EndDate;
            return(trainingDb);
        }
コード例 #4
0
        static Training ToTraining(TrainingDb trainingDb)
        {
            var training = new Training();

            training.ID          = trainingDb.Id;
            training.StaffID     = trainingDb.StaffDbId;
            training.TrainerID   = trainingDb.TrainerId;
            training.ProjectID   = trainingDb.ProjectId;
            training.ModelID     = trainingDb.ModelId;
            training.OperationID = trainingDb.OperationId;
            training.StartDate   = trainingDb.StartDate;
            training.EndDate     = trainingDb.EndDate;
            return(training);
        }
コード例 #5
0
 public void Update(TrainingDb trainingDbChanged)
 {
     using (var context = new QualificationDbContext())
     {
         var trainingDbCurrent = context.Trainings.Find(trainingDbChanged.Id);
         trainingDbCurrent.StaffDbId            = trainingDbChanged.StaffDbId;
         trainingDbCurrent.TrainerId            = trainingDbChanged.TrainerId;
         trainingDbCurrent.ProjectId            = trainingDbChanged.ProjectId;
         trainingDbCurrent.ModelId              = trainingDbChanged.ModelId;
         trainingDbCurrent.OperationId          = trainingDbChanged.OperationId;
         trainingDbCurrent.StartDate            = trainingDbChanged.StartDate;
         trainingDbCurrent.EndDate              = trainingDbChanged.EndDate;
         context.Entry(trainingDbCurrent).State = EntityState.Modified;
         context.SaveChanges();
     }
 }