Changeset afefe75 for FarmatikoServices/Services
- Timestamp:
- 02/04/21 21:46:29 (4 years ago)
- Branches:
- master
- Children:
- ac51326
- Parents:
- de9d697
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/Services/Service.cs
rde9d697 rafefe75 1 using FarmatikoData.FarmatikoRepoInterfaces; 1 using FarmatikoData.DTOs; 2 using FarmatikoData.FarmatikoRepoInterfaces; 2 3 using FarmatikoData.Models; 3 4 using FarmatikoServices.FarmatikoServiceInterfaces; … … 42 43 } 43 44 44 public async Task< IEnumerable<Medicine>> GetMedicines()45 public async Task<List<MedicineDTO>> GetMedicines() 45 46 { 46 47 var Medicines = await _repository.GetMedicinesAsync(); 47 return Medicines; 48 List<MedicineDTO> list = new List<MedicineDTO>(); 49 var listPHMedicines = await _repository.GetAllPHMedicines(); 50 foreach(var med in Medicines) 51 { 52 var heads = listPHMedicines.Where(x => x.MedicineId == med.Id).Select(x => x.Head).ToList(); 53 List<string> headNames = new List<string>(); 54 headNames = heads.Select(x => x.Name).ToList(); 55 MedicineDTO medicine = new MedicineDTO() 56 { 57 Name = med.Name, 58 Manufacturer = med.Manufacturer, 59 Packaging = med.Packaging, 60 Form = med.Form, 61 Price = med.Price, 62 Strength = med.Strength, 63 WayOfIssuing = med.WayOfIssuing, 64 HeadNames = headNames 65 }; 66 67 list.Add(medicine); 68 } 69 70 return list; 48 71 } 49 72 … … 54 77 } 55 78 56 public async Task< IEnumerable<Pharmacy>> GetPharmacies()79 public async Task<List<PharmacyDTO>> GetPharmacies() 57 80 { 58 81 var Pharmacies = await _repository.GetPharmacies(); 59 return Pharmacies; 82 List<PharmacyDTO> pharmacies = new List<PharmacyDTO>(); 83 84 foreach(var pharm in Pharmacies) 85 { 86 PharmacyDTO pharmacyDTO = new PharmacyDTO() 87 { 88 Name = pharm.Name, 89 Location = pharm.Location, 90 Address = pharm.Address, 91 WorkAllTime = pharm.WorkAllTime, 92 HeadName = pharm.PharmacyHead.Name 93 }; 94 pharmacies.Add(pharmacyDTO); 95 } 96 return pharmacies; 60 97 } 61 98
Note:
See TracChangeset
for help on using the changeset viewer.