public void Delete(TrainingDb trainingDb) { using (var context = new QualificationDbContext()) { context.Entry(trainingDb).State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(TrainingDb trainingDb) { using (var context = new QualificationDbContext()) { context.Trainings.Add(trainingDb); context.SaveChanges(); } }
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); }
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); }
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(); } }