예제 #1
0
 public string insertTrainingPlan(trainingPlan trainingPlan)
 {
     try
     {
         trainingPlan.available = true;
         context.trainingPlan.Add(trainingPlan);
         context.SaveChanges();
         return(CONSTANTES.CONSTANTES.ServiceResponse.ok);
     }
     catch (Exception e)
     {
         return(CONSTANTES.CONSTANTES.ServiceResponse.error);
     }
 }
 // POST: api/TrainingPlans
 public IHttpActionResult Post([FromBody] trainingPlan value)
 {
     try
     {
         return(ResponseMessage(Request.CreateResponse(new
         {
             response = userService.insertTrainingPlan(value)
         })));
     }
     catch (Exception e)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.ToString())));
     }
 }
예제 #3
0
 public string updateTrainingPlan(trainingPlan trainingPlan)
 {
     try
     {
         var result = context.trainingPlan.FirstOrDefault(x => x.id == trainingPlan.id);
         if (result != null)
         {
             result.name      = trainingPlan.name;
             result.startDate = trainingPlan.startDate;
             result.endDate   = trainingPlan.endDate;
             //if (result.athelete != null)
             //{
             //    result.athleteId = trainingPlan.athelete.id;
             //    result.athelete = trainingPlan.athelete;
             //}
             context.SaveChanges();
         }
         return(CONSTANTES.CONSTANTES.ServiceResponse.ok);
     }
     catch (Exception e)
     {
         return(CONSTANTES.CONSTANTES.ServiceResponse.error);
     }
 }
 public string updateTrainingPlan(trainingPlan trainingPlan)
 {
     return(trainingPlanRepository.updateTrainingPlan(trainingPlan));
 }
 public string insertTrainingPlan(trainingPlan trainingPlan)
 {
     return(trainingPlanRepository.insertTrainingPlan(trainingPlan));
 }