Beispiel #1
0
 public JsonResult AddUpdateMedications(long mid, PatientMedication_Custom medication)
 {
     try
     {
         if (medication.medicineName == null || medication.medicineName == "" || !Regex.IsMatch(medication.medicineName, "^[0-9a-zA-Z ]+$"))
         {
             ApiResultModel apiresult = new ApiResultModel();
             apiresult.message = "Invalid medicine name.Only letters and numbers are allowed.";
             return(Json(new { Success = true, ApiResultModel = apiresult }));
         }
         MedicationRepository objRepo = new MedicationRepository();
         if (mid == 0)
         {
             ApiResultModel apiresult = new ApiResultModel();
             apiresult = objRepo.AddMedication(medication);
             return(Json(new { Success = true, ApiResultModel = apiresult }));
         }
         else
         {
             ApiResultModel apiresult = new ApiResultModel();
             apiresult = objRepo.EditMedication(mid, medication);
             return(Json(new { Success = true, ApiResultModel = apiresult }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { Message = ex.Message }));
     }
 }
Beispiel #2
0
 public IHttpActionResult AddMedication(MedicationAddRequest request)
 {
     try
     {
         _medicationRepository.AddMedication(request);
         return(Ok("success"));
     }
     catch
     {
         return(BadRequest("failed"));
     }
 }