public void CreatePatientService(long invoiceID, IList <PatientService> patientServices) { using (PatientServiceRepository repository = new PatientServiceRepository()) { foreach (PatientService patientervice in patientServices) { patientervice.InvoiceID = invoiceID; repository.Insert(patientervice); } repository.Commit(); } }
//[ValidateAntiForgeryToken] public JsonResult CreatePatientService(IList <PatientService> patientServices) { List <PatientService> PatientServiceList = new List <PatientService>(); //if (ModelState.IsValid) { using (PatientServiceRepository repository = new PatientServiceRepository()) { foreach (PatientService patientervice in patientServices) { PatientService PatientService = new PatientService(); patientervice.UserId = GetLoggedinUserInfo().UserId; PatientService = repository.Insert(patientervice); PatientServiceList.Add(PatientService); } repository.Commit(); // repository.Insert(patientService); // repository.Commit(); // patient = repository.GetByPhoneNumber(patient.PhoneNumber); } foreach (PatientService patientervice in PatientServiceList) { using (ItemRepository itemRepository = new ItemRepository()) { Item item = new Item(); patientervice.Item = item; Item cItem = itemRepository.GetById(patientervice.ItemId); patientervice.Item.Id = cItem.Id; patientervice.Item.Name = cItem.Name; patientervice.Item.MedicalTypeId = cItem.MedicalTypeId; if (cItem.ItemCategory != null) { patientervice.Item.GenericName = cItem.ItemCategory.Name; patientervice.Item.ItemCategory = new ItemCategory(); patientervice.Item.ItemCategory.Name = cItem.ItemCategory.Name; } patientervice.Item.ReferralAllowed = cItem.ReferralAllowed; } } } return(Json(PatientServiceList, JsonRequestBehavior.AllowGet)); }