public ApiResultModel AddPharmacy(PatientPharmacy_Custom pharmacy) { var strContent = JsonConvert.SerializeObject(pharmacy); var response = ApiConsumerHelper.PostData("api/addupdatePatientPharmacy", strContent); var result = JsonConvert.DeserializeObject <ApiResultModel>(response); return(result); }
public async Task <HttpResponseMessage> AddPharmacy(PatientPharmacy_Custom model) { Patient patient = new Patient(); try { if (model.pharmacy == "" || model.pharmacy == null) { response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel { ID = 0, message = "Invalid pharmacy name. Only letters and numbers are allowed." }); return(response); } if (model.patientID == 0 || model.patientID == null) { response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel { ID = 0, message = "Invalid patient ID" }); return(response); } patient = db.Patients.Where(m => m.patientID == model.patientID).FirstOrDefault(); if (patient == null) { response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel { ID = 0, message = "Patient record not found." }); return(response); } patient.pharmacy = model.pharmacy; patient.pharmacyaddress = model.pharmacyaddress; patient.pharmacycitystatezip = model.pharmacycitystatezip; patient.pharmacyid = model.pharmacyid; patient.md = System.DateTime.Now; patient.mb = model.patientID.ToString(); db.Entry(patient).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (Exception ex) { return(ThrowError(ex, "AddPharmacy in PharmacyController.")); } response = Request.CreateResponse(HttpStatusCode.OK, new ApiResultModel { ID = Convert.ToInt64(model.pharmacyid), message = "" }); return(response); }
public ApiResultModel SavePatientPharmacy(PatientPharmacy_Custom model) { try { var strContent = JsonConvert.SerializeObject(model); var response = ApiConsumerHelper.PostData("api/addPatientPharmacy", strContent); var result = JsonConvert.DeserializeObject <ApiResultModel>(response); return(result); } catch (HttpResponseException ex) { throw ex; } }
public JsonResult AddUpdatePharmacy(PatientPharmacy_Custom pharmacy) { ApiResultModel apiresult = new ApiResultModel(); try { if (pharmacy.pharmacy == null || pharmacy.pharmacy == "" || !Regex.IsMatch(pharmacy.pharmacy, "^[0-9a-zA-Z ]+$")) { apiresult.message = "Invalid pharmacy name.Only letters and numbers are allowed."; return(Json(new { Success = true, ApiResultModel = apiresult })); } else { PatientRepository objRepo = new PatientRepository(); apiresult = objRepo.AddPharmacy(pharmacy); return(Json(new { Success = true, ApiResultModel = apiresult })); } } catch (Exception ex) { return(Json(new { Message = ex.Message })); } }