コード例 #1
0
 public AddDefinitionResponse AddDefinition(AddDefinitionRequest request)
 {
     if (string.Equals(request.Type, "description", StringComparison.InvariantCultureIgnoreCase)) {
         return AddMidtermStageDescription(request);
     }
     return AddMidtermStageKey(request);
 }
コード例 #2
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"
         };
     }
 }