예제 #1
0
 private AddDefinitionResponse AddMidtermStageKey(AddDefinitionRequest request)
 {
     try
     {
         var stageKey = request.MapTo<MidtermPhaseKeyDriver>();
         if (request.Id == 0)
         {
             var formulation = new MidtermPhaseFormulationStage { Id = request.MidtermPhaseStageId };
             stageKey.Formulation = formulation;
             DataContext.MidtermPhaseFormulationStages.Attach(formulation);
             DataContext.MidtermPhaseKeyDrivers.Add(stageKey);
         }
         else
         {
             stageKey = DataContext.MidtermPhaseKeyDrivers.First(x => x.Id == request.Id);
             stageKey.Value = request.Value;
         }
         DataContext.SaveChanges();
         return new AddDefinitionResponse
         {
             IsSuccess = true,
             Message = "New Stage has been added",
             Id = stageKey.Id,
             Value = stageKey.Value
         };
     }
     catch
     {
         return new AddDefinitionResponse
         {
             IsSuccess = false,
             Message = "An error has been occured, please contact the administrator for further information"
         };
     }
 }