public async Task <IActionResult> updateData(doctorPanelSendForEditPrescriptionViewModel[] medicines) { using (var prescription = new doctorsPrescription()) { prescription.doctorsPrescriptionID = medicines.First().prescriptionID; prescription.turnsID = medicines.First().turnsID; prescription.createDate = DateTime.Now.toShamsi(); prescription.prescriptionStatus = (int)constantConcepts.Status.success; prescription.PrescriptionDescriptions = ""; var prescriptionResult = await doctorsPrescriptionsRepository.editDoctorsPrescription(prescription); if (prescriptionResult == true) { await doctorsPrescriptionsRepository.saveChanges(); } } foreach (var item in medicines) { using (var medicine = new Medicine()) { medicine.medicineID = item.medicineID; medicine.doctorsPrescriptionID = medicines.First().prescriptionID; medicine.medicineName = item.medicineName; medicine.createDate = DateTime.Now.toShamsi(); medicine.Descriptions = ""; var medicineResult = await medicinesRpository.editMedicine(medicine); if (medicineResult == true) { await medicinesRpository.saveChanges(); } using (var howuse = new howUse()) { howuse.howUseID = item.howUseID; howuse.medicineID = item.medicineID; howuse.howUseText = item.howUseText; howuse.useFrom = item.fromDate; howuse.useTo = item.toDate; howuse.createDate = DateTime.Now.toShamsi(); howuse.Descriptions = ""; var howUseResult = await howUsesRepository.edithowUse(howuse); if (howUseResult == true) { await howUsesRepository.saveChanges(); } } } } return(RedirectToAction("Index")); }
public async Task <bool> deletehowUse(howUse howUse) { try { await Task.Run(() => db.Entry(howUse).State = EntityState.Deleted); return(true); } catch (Exception) { return(false); } }
public async Task <bool> inserthowUse(howUse howUse) { try { await db.howUses.AddAsync(howUse); return(true); } catch (Exception) { return(false); } }
public async Task <bool> deletehowUse(int id) { try { howUse find = await gethowUseById(id); await deletehowUse(find); return(true); } catch (Exception) { return(false); } }
public async Task <IActionResult> insertData(DoctorPanelNewPrescriptionViewModel[] medicines, Notes note) { doctorsPrescription doctorsPrescription = new doctorsPrescription() { turnsID = medicines.First().turnsID, createDate = DateTime.Now.toShamsi(), prescriptionStatus = (int)constantConcepts.Status.success }; var PrescriptionResult = await doctorsPrescriptionsRepository.insertDoctorsPrescription(doctorsPrescription); if (PrescriptionResult == true) { await doctorsPrescriptionsRepository.saveChanges(); } var PrescriptionLastID = doctorsPrescription.doctorsPrescriptionID; foreach (var item in medicines) { using (var medicine = new Medicine()) { medicine.doctorsPrescriptionID = PrescriptionLastID; medicine.medicineName = item.medicineName; medicine.createDate = DateTime.Now.toShamsi(); medicine.Descriptions = ""; var medicineResult = await medicinesRpository.insertMedicine(medicine); if (medicineResult == true) { await medicinesRpository.saveChanges(); } var medicineLastID = medicine.medicineID; using (var howuse = new howUse()) { howuse.medicineID = medicineLastID; howuse.howUseText = item.howUseText; howuse.useFrom = item.fromDate; howuse.useTo = item.toDate; howuse.createDate = DateTime.Now.toShamsi(); howuse.Descriptions = ""; var howUseResult = await howUsesRepository.inserthowUse(howuse); if (howUseResult == true) { await howUsesRepository.saveChanges(); } } } } using (var notes = new Notes()) { notes.createDate = DateTime.Now.toShamsi(); notes.turnsID = medicines.First().turnsID; notes.titleNote = note.titleNote; notes.fullTextNote = note.fullTextNote; var noteResult = await noteRepository.insertNotes(notes); if (noteResult == true) { await noteRepository.saveChanges(); } } return(RedirectToAction("Index")); }