public async Task <IActionResult> GetPharmacyMedicines(int id) { var medicineSelectList = _selectService.GetAllMedicines(); var medicinePharmacyR = await _pharmacyRepository.GetPharmacyMedicines(id); var result = from medicineSelect in medicineSelectList join medicinePharmacy in medicinePharmacyR on medicineSelect.Key equals medicinePharmacy.MedicineId into ps from medicine in ps.DefaultIfEmpty() select new { Id = medicineSelect.Key, Name = medicineSelect.Value, Quantity = (medicine == null ? 0 : medicine.Quantity), IsSelected = (medicine == null ? false : true) }; return(Ok(result)); }