Changeset 68454c6
- Timestamp:
- 11/15/20 19:08:48 (4 years ago)
- Branches:
- master
- Children:
- 8b13eb2
- Parents:
- 1db5673
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/admin/admin.component.ts
r1db5673 r68454c6 19 19 public requests: IPharmacyHeadRequest[] = []; 20 20 public head: IPharmacyHead = { 21 id: '',22 21 PharmacyMedicines: null, 23 22 Pharmacy: null, … … 58 57 () => console.log("PharmacyHead inserted")); 59 58 this.head = { 60 id: '',61 59 PharmacyMedicines: null, 62 60 Pharmacy: null, -
Farmatiko/ClientApp/src/app/shared/data.service.ts
r1db5673 r68454c6 180 180 //PharmacyHead PUT 181 181 updatePharmacyHead(head: IPharmacyHead) : Observable<IPharmacyHead> { 182 return this.http.put<IPharmacyHead>(this.basePharmacyHead , head)182 return this.http.put<IPharmacyHead>(this.basePharmacyHead + '/update', head) 183 183 .pipe( 184 184 map((data) => { -
Farmatiko/Controllers/PharmacyHeadController.cs
r1db5673 r68454c6 9 9 { 10 10 [ApiController] 11 [Authorize(Roles = "PharmacyHead ")]11 [Authorize(Roles = "PharmacyHead,Admin")] 12 12 public class PharmacyHeadController : Controller 13 13 { … … 36 36 } 37 37 //POST 38 38 /* 39 39 [HttpPost] 40 40 [Route("api/pharmacyhead/add")] 41 public async Task<IActionResult> AddPharmacyHead([FromBody] PharmacyHead pharmacyHead)41 public async Task<IActionResult> AddPharmacyHead([FromBody] PharmacyHead pharmacyHead) 42 42 { 43 43 bool Success = await _PHService.Add(pharmacyHead); … … 52 52 }*/ 53 53 [HttpPut] 54 [Route("api/pharmacyhead")] 55 [Authorize(Roles = "Admin")] 56 [Authorize(Roles = "PharmacyHead")] 54 [Route("api/pharmacyhead/update")] 57 55 public async Task UpdatePharmacyHead([FromBody]PharmacyHead pharmacyHead) 58 56 { -
FarmatikoData/FarmatikoDataContext.cs
r1db5673 r68454c6 27 27 .ToTable("Medicines"); 28 28 29 modelBuilder.Entity<Pharmacy>() 30 .ToTable("Pharmacies"); 31 29 32 modelBuilder.Entity<PharmacyHeadMedicine>() 30 33 .HasKey(phm => new { phm.PheadId, phm.MedicineId }); … … 44 47 .HasForeignKey(k => k.PheadId); 45 48 49 /* 50 modelBuilder.Entity<CarDetails>() 51 .ToTable("CarDetails"); 52 53 modelBuilder.Entity<CarDetails>() 54 .Property(x => x.Type) 55 .HasConversion<int>(); 56 57 modelBuilder.Entity<CarDetails>() 58 .HasMany(x => x.ImageUrls) 59 .WithOne(y => y.Car) 60 .HasForeignKey(y => y.CarId); 61 */ 62 63 /*modelBuilder.Entity<PharmacyHead>() 64 .HasMany(x => x.PharmaciesList);*/ 65 46 66 base.OnModelCreating(modelBuilder); 47 67 } -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r1db5673 r68454c6 119 119 return pharms; 120 120 } 121 122 public void DeletePHMedicine(int id, int phId, int medId) 123 { 124 var PH = _context.PharmacyHeadMedicines.Where(x => x.PheadId == phId).Single(); 125 var PHMed = _context.PharmacyHeadMedicines.Where(x => x.MedicineId == medId).Single(); 126 var PHID = _context.PharmacyHeadMedicines.Where(x => x.Id == id).Single(); 127 _context.PharmacyHeadMedicines.Remove(PHID); 128 _context.SaveChanges(); 129 } 121 130 } 122 131 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r1db5673 r68454c6 259 259 260 260 }).ToList(); 261 return Medicines; 261 return Medicines; 262 262 } 263 263 -
FarmatikoData/FarmatikoRepoInterfaces/IPHRepo.cs
r1db5673 r68454c6 22 22 PharmacyHead GetPharmacyHead(string head); 23 23 List<Pharmacy> GetPharmacies(); 24 void DeletePHMedicine(int id, int phId, int medId); 24 25 } 25 26 } -
FarmatikoData/Models/Pharmacy.cs
r1db5673 r68454c6 27 27 } 28 28 public int PheadId { get; set; } 29 public PharmacyHead PHead { get; set; }29 public PharmacyHead PHead { get; internal set; } 30 30 } 31 31 } -
FarmatikoData/Models/PharmacyHead.cs
r1db5673 r68454c6 21 21 [JsonProperty("Passwd")] 22 22 public string Password { get; set; } 23 24 23 25 [JsonProperty("PharmacyMedicines")] 24 26 public List<Medicine> MedicineList { get; set; } 25 [Required]26 27 [JsonProperty("Pharmacy")] 27 28 public ICollection<Pharmacy> PharmaciesList { get; set; } -
FarmatikoServices/Services/PHService.cs
r1db5673 r68454c6 66 66 if (pharmacyHead.PharmaciesList.Count() == 0) 67 67 pharmacyHead.PharmaciesList = null; 68 if (pharmacyHead.MedicineList.Count() == 0) 69 pharmacyHead.MedicineList = null; 68 70 69 71 70 phead.PHMedicineList = _repository.GetPHMedicines(phead.Email); … … 75 74 phead.MedicineList = pharmacyHead.MedicineList; 76 75 List<PharmacyHeadMedicine> list = new List<PharmacyHeadMedicine>(); 77 76 if (pharmacyHead.MedicineList.Count() == 0) 77 { 78 phead.MedicineList = null; 79 int PHMId = phead.PHMedicineList.Select(x => x.Id).Single(); 80 int phId = phead.PHMedicineList.Select(x => x.PheadId).Single(); 81 int medId = phead.PHMedicineList.Select(x => x.MedicineId).Single(); 82 _iPHRepo.DeletePHMedicine(PHMId, phId, medId); 83 return; 84 } 78 85 foreach (var med in phead.MedicineList) 79 86 { -
FarmatikoServices/Services/Service.cs
r1db5673 r68454c6 132 132 if (pharmacyHead != null) 133 133 { 134 var Medicines = await _repository.GetMedicinesAsync();134 /*var Medicines = await _repository.GetMedicinesAsync(); 135 135 foreach (var med in Medicines) 136 136 { 137 137 pharmacyHead.MedicineList.Add(med); 138 } 138 }*/ 139 139 140 140 await _repository.AddPharmacyHead(pharmacyHead);
Note:
See TracChangeset
for help on using the changeset viewer.