Changeset 8e74e2f
- Timestamp:
- 11/16/20 03:55:10 (4 years ago)
- Branches:
- master
- Children:
- db484c9
- Parents:
- 8b13eb2
- Files:
-
- 29 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/admin/admin.component.html
r8b13eb2 r8e74e2f 12 12 <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"> 13 13 <ul class="navbar-nav flex-grow"> 14 <li>Administration panel</li> 14 <li>Administration panel:</li> 15 <li> Logged as <p *ngIf="head">{{adminHead.Name}}</p> </li> 16 <li (click)="logout()" class="btn btn-link"><a>Logout</a></li> 15 17 </ul> 16 18 </div> … … 18 20 </nav> 19 21 </header> 20 <mat-tab-group mat-stretch-tabs >22 <mat-tab-group mat-stretch-tabs dynamicHeight> 21 23 <mat-tab label="Claiming requests"> 22 24 <div class="wrapper"> -
Farmatiko/ClientApp/src/app/admin/admin.component.ts
r8b13eb2 r8e74e2f 7 7 import { EditPharmacyHeadDialogComponent } from '../dialogs/edit-pharmacy-head-dialog/edit-pharmacy-head-dialog.component'; 8 8 import { PharmacyDialogComponent } from '../dialogs/pharmacy-dialog/pharmacy-dialog.component'; 9 import { PharmacyHeadDialogComponent } from '../nav-menu/dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component'; 9 import { PharmacyHeadDialogComponent } from '../dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component'; 10 import { AuthService } from '../shared/services/auth.service'; 10 11 11 12 … … 19 20 public requests: IPharmacyHeadRequest[] = []; 20 21 public head: IPharmacyHead = { 21 PharmacyMedicines: null,22 Pharmacy: null,23 22 Email: '', 24 23 Passwd: '', 25 24 Name: '' 26 25 }; 26 public adminHead: IPharmacyHead; 27 27 28 constructor(private dataService: DataService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router) {28 constructor(private dataService: DataService, private authService: AuthService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router) { 29 29 30 30 } 31 31 32 32 ngOnInit(): void { 33 this.authService.getUser() 34 .subscribe((data) => { 35 console.log(data); 36 this.adminHead = data; 37 }, 38 (err: any) => console.log(err), 39 () => console.log('User data retrieved')); 40 33 41 this.dataService.getPharmacyHeads() 34 42 .subscribe((pHeads: IPharmacyHead[]) => { … … 39 47 40 48 this.dataService.getClaimingRequests() 41 .subscribe((pRequests: IPharmacyHeadRequest[]) => {42 this.requests = pRequests;43 },44 (err: any) => console.log(err),45 () => console.log("PharmacyHead data retrieved"));49 .subscribe((pRequests: IPharmacyHeadRequest[]) => { 50 this.requests = pRequests; 51 }, 52 (err: any) => console.log(err), 53 () => console.log("PharmacyHead data retrieved")); 46 54 } 47 55 … … 57 65 () => console.log("PharmacyHead inserted")); 58 66 this.head = { 59 PharmacyMedicines: null,60 Pharmacy: null,61 67 Email: '', 62 68 Passwd: '', … … 83 89 dialogRef.afterClosed().subscribe((editedHead: IPharmacyHead) => { 84 90 if(editedHead){ 91 console.log(editedHead); 85 92 this.heads = this.heads.filter(x => x !== eHead); 86 93 this.heads.push(editedHead); … … 142 149 } 143 150 151 logout() { 152 this.authService.logout(); 153 } 154 144 155 openSnackBar(message: string, action: string) : MatSnackBarRef<SimpleSnackBar> { 145 156 return this.snackBar.open(message, action, { -
Farmatiko/ClientApp/src/app/app.module.ts
r8b13eb2 r8e74e2f 26 26 import { EditPharmacyDialogComponent } from './dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component'; 27 27 import { EditPharmacyHeadDialogComponent } from './dialogs/edit-pharmacy-head-dialog/edit-pharmacy-head-dialog.component'; 28 import { PharmacyHeadDialogComponent } from './nav-menu/dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component'; 28 import { PharmacyHeadDialogComponent } from './dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component'; 29 import { AddMedicineDialogComponent } from './dialogs/add-medicine-dialog/add-medicine-dialog.component'; 30 import { ListMedicinesDialogComponent } from './dialogs/list-medicines-dialog/list-medicines-dialog.component'; 29 31 30 32 @NgModule({ … … 44 46 EditPharmacyDialogComponent, 45 47 EditPharmacyHeadDialogComponent, 46 PharmacyHeadDialogComponent 48 PharmacyHeadDialogComponent, 49 AddMedicineDialogComponent, 50 ListMedicinesDialogComponent 47 51 ], 48 52 imports: [ -
Farmatiko/ClientApp/src/app/counter/counter.component.css
r8b13eb2 r8e74e2f 12 12 13 13 .header { 14 min-height: 64px;15 14 padding: 8px 24px 0; 16 15 } -
Farmatiko/ClientApp/src/app/counter/counter.component.html
r8b13eb2 r8e74e2f 2 2 <app-nav-menu></app-nav-menu> 3 3 4 <mat-tab-group mat-stretch-tabs>4 <mat-tab-group dynamicHeight mat-stretch-tabs> 5 5 <mat-tab class="tab" label="Здравствени установи"> 6 6 <div class="wrapper"> -
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.css
r8b13eb2 r8e74e2f 15 15 16 16 .header { 17 min-height: 64px;18 17 padding: 8px 24px 0; 19 18 } … … 31 30 padding: 1em 0; 32 31 } 32 33 .btns { 34 display: flex; 35 flex-direction: row; 36 justify-content: flex-start; 37 } 38 39 .btns button { 40 margin: 0.5em 0.5em 0.5em 0; 41 } -
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.html
r8b13eb2 r8e74e2f 13 13 <ul class="navbar-nav flex-grow"> 14 14 <li>Logged as <p *ngIf="head">{{head.Name}}</p> </li> 15 <li (click)="logout()" class="btn btn-link"><a>Logout</a></li>16 15 </ul> 17 16 </div> … … 20 19 <mat-menu #menu="matMenu"> 21 20 <button mat-menu-item [routerLink]="['/']"><mat-icon>directions</mat-icon>Почетна</button> 21 <button mat-menu-item (click)="logout()"><mat-icon>exit_to_app</mat-icon>Одјави се</button> 22 22 </mat-menu> 23 23 </div> … … 25 25 </header> 26 26 27 <mat-tab-group mat-stretch-tabs>27 <mat-tab-group dynamicHeight mat-stretch-tabs> 28 28 <mat-tab class="tab" label="Мои аптеки"> 29 29 <div class="wrapper"> … … 88 88 <div class="header"> 89 89 <h2>Достапни лекови</h2> 90 <mat-form-field> 90 <div class="btns"> 91 <button mat-raised-button color="primary" (click)="saveDeletedMedicines()" [disabled]="editedMedicine==false">Зачувај ги промените</button> 92 <button mat-raised-button color="accent" aria-label="Add medicine" (click)="addMedicine()">Додај нов лек</button> 93 <button mat-raised-button color="accent" aria-label="Add medicine" (click)="addMedicinesFromList()">Додај постоечки лекови</button> 94 </div><br/> 95 <mat-slide-toggle (click)="switchEditMedicineMode()">Edit mode</mat-slide-toggle> 96 97 <mat-form-field *ngIf="!medicinesEditMode"> 91 98 <input matInput (keyup)="applyFilterMedicines($event.target.value)" placeholder="Пронајди лек"> 92 99 </mat-form-field> 93 100 </div> 94 101 <table class='table table-striped table-bordered table-sm' cellspacing="0" width="100%" aria-labelledby="tableLabel" *ngIf="head"> 95 102 <thead> … … 102 109 <th>Цена</th> 103 110 <th>Пакување</th> 111 <th>Контроли</th> 104 112 </tr> 105 113 </thead> 106 114 <tbody> 107 <tr *ngFor="let medicine of head.PharmacyMedicines"> 108 <td><a (click)="openMedicineDialog(medicine)">{{ medicine.name }}</a></td> 109 <td>{{ medicine.strength }}</td> 110 <td>{{ medicine.form }}</td> 111 <td>{{ medicine.wayOfIssuing }}</td> 112 <td>{{ medicine.manufacturer }}</td> 113 <td>{{ medicine.price }}</td> 114 <td>{{ medicine.packaging }}</td> 115 <td><a (click)="deleteMedicine(medicine)">Delete</a></td> 115 <tr *ngFor="let medicine of filteredMedicines"> 116 <td *ngIf="!medicinesEditMode"><a (click)="openMedicineDialog(medicine)">{{ medicine.name }}</a></td> 117 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.name" name="medname"></mat-form-field></td> 118 <td *ngIf="!medicinesEditMode">{{ medicine.strength }}</td> 119 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.strength" name="medstr"></mat-form-field></td> 120 <td *ngIf="!medicinesEditMode">{{ medicine.form }}</td> 121 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.form" name="medform"></mat-form-field></td> 122 <td *ngIf="!medicinesEditMode">{{ medicine.wayOfIssuing }}</td> 123 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.wayOfIssuing" name="medwayOfIssuing"></mat-form-field></td> 124 <td *ngIf="!medicinesEditMode">{{ medicine.manufacturer }}</td> 125 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.manufacturer" name="medmanufacturer"></mat-form-field></td> 126 <td *ngIf="!medicinesEditMode">{{ medicine.price }}</td> 127 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.price" name="medprice"></mat-form-field></td> 128 <td *ngIf="!medicinesEditMode">{{ medicine.packaging }}</td> 129 <td *ngIf="medicinesEditMode"><mat-form-field appearance="fill"><input matInput [(ngModel)]="medicine.packaging" name="medpackaging"></mat-form-field></td> 130 <td> 131 <button mat-mini-fab color="warn" aria-label="Delete medicine" (click)="deleteMedicine(medicine)"> 132 <mat-icon>delete</mat-icon> 133 </button> 134 </td> 116 135 </tr> 117 136 </tbody> -
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts
r8b13eb2 r8e74e2f 9 9 import { ActivatedRoute, Router } from '@angular/router'; 10 10 import { AuthService } from '../shared/services/auth.service'; 11 import { AddMedicineDialogComponent } from '../dialogs/add-medicine-dialog/add-medicine-dialog.component'; 12 import { ListMedicinesDialogComponent } from '../dialogs/list-medicines-dialog/list-medicines-dialog.component'; 11 13 12 14 @Component({ … … 21 23 public filteredMedicines: IMedicine[] = []; 22 24 public request: IPharmacyHeadRequest; 25 editedMedicine: boolean = false; 26 medicinesEditMode: boolean = false; 23 27 24 28 constructor(private dataService: DataService, private authService: AuthService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router, private route: ActivatedRoute) { … … 37 41 .subscribe((pharmacy: IPharmacy[]) => { 38 42 this.pharmacies = pharmacy; 43 this.head.Pharmacy.forEach((pharma) => { 44 this.filteredPharmacies = this.pharmacies = this.pharmacies.filter(x => x == pharma); 45 }); 39 46 }, 40 47 (err: any) => console.log(err), 41 48 () => console.log('Pharmacy data retrieved')); 49 this.filteredMedicines = this.head.PharmacyMedicines; 42 50 } 43 51 … … 83 91 deleteMedicine(medicine: IMedicine){ 84 92 this.head.PharmacyMedicines = this.head.PharmacyMedicines.filter(x => x !== medicine); 93 this.filteredMedicines = this.head.PharmacyMedicines; 94 this.editedMedicine = true; 95 } 96 97 saveDeletedMedicines() { 85 98 this.dataService.updatePharmacyHead(this.head) 86 .subscribe((hd: IPharmacyHead) => { 87 if(hd) { 88 this.openSnackBar("Success! Medicine deleted", "OK"); 89 } 90 else { 91 this.openSnackBar("Unable to delete Medicine", "Try again"); 92 } 93 }, 94 (err: any) => console.log(err), 95 () => console.log('Update sent!')); 99 .subscribe((hd: IPharmacyHead) => { 100 if(hd) { 101 this.openSnackBar("Success! Medicine deleted", "OK"); 102 this.editedMedicine = false; 103 } 104 else { 105 this.openSnackBar("Unable to delete Medicine", "Try again"); 106 } 107 }, 108 (err: any) => console.log(err), 109 () => console.log('Update sent!')); 96 110 } 97 111 … … 99 113 console.log("applyFilterMedicines works!") 100 114 if(filterValue) { 101 this.dataService.searchMedicines(filterValue) 102 .subscribe((medicine: IMedicine[]) => { 103 this.filteredMedicines = medicine; 104 }, 105 (err: any) => console.log(err), 106 () => console.log('Medicine data retrieved')); 115 this.filteredMedicines = this.filteredMedicines.filter(x => x.name.toLocaleLowerCase().includes(filterValue.toLocaleLowerCase())); 107 116 } 108 117 else { 109 118 this.filteredMedicines = this.head.PharmacyMedicines; 119 } 120 } 121 122 addMedicine() { 123 let dialogRef = this.dialog.open(AddMedicineDialogComponent, { 124 width: 'auto' 125 }); 126 dialogRef.afterClosed().subscribe((newMedicine: IMedicine) => { 127 if(newMedicine){ 128 this.head.PharmacyMedicines.push(newMedicine); 129 this.filteredMedicines = this.head.PharmacyMedicines; 130 if(this.editedMedicine == false) { 131 this.editedMedicine = true; 132 } 133 this.openSnackBar("Success! Medicine added, please save changes now", "OK"); 134 } 135 else { 136 this.openSnackBar("Failed! Please try again", "OK"); 137 } 138 }, () => this.openSnackBar("Failed! Please try again", "OK")); 139 } 140 141 addMedicinesFromList() { 142 let dialogRef = this.dialog.open(ListMedicinesDialogComponent, { 143 width: 'auto', 144 height: 'auto' 145 }); 146 dialogRef.afterClosed().subscribe((listMedicines: IMedicine[]) => { 147 if(listMedicines){ 148 listMedicines.forEach((medicine) => { 149 this.head.PharmacyMedicines = this.head.PharmacyMedicines.filter(x => x != medicine); 150 this.head.PharmacyMedicines.push(medicine); 151 this.filteredMedicines = this.head.PharmacyMedicines; 152 }); 153 if(this.editedMedicine == false) { 154 this.editedMedicine = true; 155 } 156 this.openSnackBar("Success! Medicines added, please save changes now", "OK"); 157 } 158 else { 159 this.openSnackBar("Failed! Please try again", "OK"); 160 } 161 }, () => this.openSnackBar("Failed! Please try again", "OK")); 162 } 163 164 switchEditMedicineMode() { 165 this.medicinesEditMode = !this.medicinesEditMode; 166 if(this.editedMedicine == false) { 167 this.editedMedicine = true; 110 168 } 111 169 } … … 117 175 .subscribe((pharmacy: IPharmacy[]) => { 118 176 this.filteredPharmacies = pharmacy; 177 this.head.Pharmacy.forEach((pharma) => { 178 this.filteredPharmacies = this.filteredPharmacies.filter(x => x == pharma); 179 }); 119 180 }, 120 181 (err: any) => console.log(err), … … 123 184 else { 124 185 this.filteredPharmacies = this.pharmacies; 125 } 186 } 126 187 } 127 188 … … 138 199 139 200 openEditPharmacyDialog(pharmacy: IPharmacy): void { 201 console.log(pharmacy); 140 202 let dialogRef = this.dialog.open(EditPharmacyDialogComponent, { 141 203 width: '450px', -
Farmatiko/ClientApp/src/app/dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component.html
r8b13eb2 r8e74e2f 13 13 <div class="form-group"> 14 14 <label>Location</label> 15 <input type="text" class="form-control" [(ngModel)]="pharmacy.location" #email="ngModel" required />15 <input type="text" class="form-control" name="location" [(ngModel)]="pharmacy.location" #location="ngModel" required /> 16 16 <div class="alert alert-danger" [hidden]="pharmacy.location">Location is required</div> 17 17 </div> 18 18 <div class="form-group"> 19 19 <label>Work 24/7</label> 20 <br />21 20 <div class="radio"> 22 21 <label> 23 <input type="radio" name="workAllTime" [(ngModel)]="pharmacy.workAllTime" #workAllTime="ngModel" value="true" required /> 24 Да 25 </label> 26 </div> 27 <div class="radio"> 28 <label> 29 <input type="radio" name="workAllTime" [(ngModel)]="pharmacy.workAllTime" #workAlltime="ngModel" value="false" required /> 30 Не 22 <input type="checkbox" name="workAllTime" [(ngModel)]="pharmacy.workAllTime" #workAllTime="ngModel" [value]="pharmacy.workAllTime"/> 31 23 </label> 32 24 </div> -
Farmatiko/ClientApp/src/app/dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component.ts
r8b13eb2 r8e74e2f 19 19 20 20 save() { 21 console.log(this.pharmacy); 21 22 this.dialogRef.close(this.pharmacy); 22 23 } -
Farmatiko/ClientApp/src/app/dialogs/list-medicines-dialog/list-medicines-dialog.component.html
r8b13eb2 r8e74e2f 21 21 <tbody> 22 22 <tr *ngFor="let medicine of filteredListMedicines"> 23 <td> >{{ medicine.name }}</td>23 <td>{{ medicine.name }}</td> 24 24 <td>{{ medicine.strength }}</td> 25 25 <td>{{ medicine.form }}</td> -
Farmatiko/ClientApp/src/app/dialogs/list-medicines-dialog/list-medicines-dialog.component.ts
r8b13eb2 r8e74e2f 10 10 }) 11 11 export class ListMedicinesDialogComponent implements OnInit { 12 medicines: IMedicine[] ;12 medicines: IMedicine[] = []; 13 13 listMedicines: IMedicine[]; 14 14 filteredListMedicines: IMedicine[]; … … 30 30 this.medicines = this.medicines.filter(x => x != selectedMedicine); 31 31 } 32 else { 33 this.medicines.push(selectedMedicine); 34 } 32 this.medicines.push(selectedMedicine); 35 33 } 36 34 -
Farmatiko/ClientApp/src/app/home/home.component.css
r8b13eb2 r8e74e2f 12 12 13 13 .header { 14 min-height: 64px;15 14 padding: 8px 24px 0; 16 15 } -
Farmatiko/ClientApp/src/app/home/home.component.html
r8b13eb2 r8e74e2f 1 1 <app-nav-menu></app-nav-menu> 2 2 3 <mat-tab-group mat-stretch-tabs>3 <mat-tab-group dynamicHeight mat-stretch-tabs> 4 4 <mat-tab class="tab" label="Лекови"> 5 5 <div class="wrapper"> -
Farmatiko/ClientApp/src/app/nav-menu/nav-menu.component.html
r8b13eb2 r8e74e2f 26 26 <a class="nav-link text-dark" [routerLink]="['/koronavirus']">Коронавирус</a> 27 27 </li> 28 <li *ngIf="loggedIn"> 29 <button mat-button [matMenuTriggerFor]="menu"><mat-icon>more_vert</mat-icon></button> 30 <mat-menu #menu="matMenu"> 31 <button mat-menu-item [routerLink]="['/dashboard']"><mat-icon>dashboard</mat-icon>Контролна табла</button> 32 <button mat-menu-item (click)="logout()"><mat-icon>exit_to_app</mat-icon>Одјави се</button> 33 </mat-menu> 34 </li> 28 35 </ul> 29 36 </div> -
Farmatiko/ClientApp/src/app/nav-menu/nav-menu.component.ts
r8b13eb2 r8e74e2f 1 import { Component } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core'; 2 import { AuthService } from '../shared/services/auth.service'; 2 3 3 4 @Component({ … … 6 7 styleUrls: ['./nav-menu.component.css'] 7 8 }) 8 export class NavMenuComponent {9 export class NavMenuComponent implements OnInit { 9 10 isExpanded = false; 11 loggedIn: boolean = false; 12 13 constructor(private authService: AuthService) { 14 15 } 16 17 ngOnInit(): void { 18 if(localStorage.getItem('access_token')) { 19 this.loggedIn = true; 20 } 21 } 22 23 logout() { 24 this.authService.logout(); 25 } 10 26 11 27 collapse() { -
Farmatiko/ClientApp/src/custom-theme.scss
r8b13eb2 r8e74e2f 14 14 // hue. Available color palettes: https://material.io/design/color/ 15 15 $Farmatiko-primary: mat-palette($mat-green); 16 $Farmatiko-accent: mat-palette($mat- pink, A200, A100, A400);16 $Farmatiko-accent: mat-palette($mat-cyan); 17 17 18 18 // The warn palette is optional (defaults to red). -
Farmatiko/ClientApp/src/index.html
r8b13eb2 r8e74e2f 7 7 8 8 <meta name="viewport" content="width=device-width, initial-scale=1" /> 9 <link rel="icon" type="image/x-icon" href=" favicon.ico" />9 <link rel="icon" type="image/x-icon" href="./favicon.ico" /> 10 10 <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet"> 11 11 <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> -
Farmatiko/Controllers/FarmatikoController.cs
r8b13eb2 r8e74e2f 24 24 { 25 25 //_JSONservice.DownloadPharmaciesExcel(); 26 //_JSONservice.GetProcessedHealthcareWorkersFromJSON();26 _JSONservice.GetProcessedHealthcareWorkersFromJSON(); 27 27 //_JSONservice.GetProcessedHealthFacilitiesFromJSON(); 28 28 //_JSONservice.GetProcessedMedicinesFromJSON(); 29 _JSONservice.GetProcessedPandemicsFromJSONApi();29 //_JSONservice.GetProcessedPandemicsFromJSONApi(); 30 30 } 31 31 [HttpGet] -
Farmatiko/Controllers/PharmacyHeadController.cs
r8b13eb2 r8e74e2f 30 30 [HttpGet] 31 31 [Route("api/pharmacyhead/{Id}")] 32 public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute] int Id)32 public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute] int Id) 33 33 { 34 34 var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id); … … 36 36 } 37 37 //POST 38 /*39 [HttpPost]40 [Route("api/pharmacyhead/add")]41 public async Task<IActionResult> AddPharmacyHead([FromBody] PharmacyHead pharmacyHead)42 {43 bool Success = await _PHService.Add(pharmacyHead);44 return Ok(Success);45 }*/38 /* 39 [HttpPost] 40 [Route("api/pharmacyhead/add")] 41 public async Task<IActionResult> AddPharmacyHead([FromBody] PharmacyHead pharmacyHead) 42 { 43 bool Success = await _PHService.Add(pharmacyHead); 44 return Ok(Success); 45 }*/ 46 46 47 47 /*[HttpPost] … … 49 49 public async Task<int> Login([FromBody]PharmacyHead pharmacyHead) 50 50 { 51 return await _PHService.Login(pharmacyHead); 51 return await _PHService.Login(pharmacyHead); 52 52 }*/ 53 53 [HttpPut] 54 54 [Route("api/pharmacyhead/update")] 55 public async Task UpdatePharmacyHead([FromBody] PharmacyHead pharmacyHead)55 public async Task UpdatePharmacyHead([FromBody] PharmacyHead pharmacyHead) 56 56 { 57 57 await _PHService.UpdatePharmacyHead(pharmacyHead); … … 59 59 [HttpPost] 60 60 [Route("api/pharmacyhead/requests")] 61 public async Task<IActionResult> ClaimPharmacy([FromBody] RequestPharmacyHead pharmacy)61 public async Task<IActionResult> ClaimPharmacy([FromBody] RequestPharmacyHead pharmacy) 62 62 { 63 63 bool Success = await _PHService.ClaimPharmacy(pharmacy); … … 78 78 return Ok(Success); 79 79 } 80 80 81 81 } 82 82 } -
FarmatikoData/FarmatikoDataContext.cs
r8b13eb2 r8e74e2f 7 7 { 8 8 public FarmatikoDataContext(DbContextOptions options) : base(options) { } 9 9 10 10 11 11 public virtual DbSet<HealthFacility> HealthFacilities { get; set; } … … 18 18 public virtual DbSet<User> Users { get; set; } 19 19 public virtual DbSet<PharmacyHeadMedicine> PharmacyHeadMedicines { get; set; } 20 20 21 21 protected override void OnModelCreating(ModelBuilder modelBuilder) 22 22 { 23 modelBuilder.UseSerialColumns(); 24 23 25 modelBuilder.Entity<PharmacyHead>() 24 26 .ToTable("PharmacyHeads"); … … 29 31 modelBuilder.Entity<Pharmacy>() 30 32 .ToTable("Pharmacies"); 33 34 modelBuilder.Entity<Medicine>() 35 .Property(x => x.Id) 36 .HasIdentityOptions(startValue: 1); 37 38 modelBuilder.Entity<Pharmacy>() 39 .Property(x => x.Id) 40 .HasIdentityOptions(startValue: 1); 41 42 modelBuilder.Entity<PharmacyHead>() 43 .Property(x => x.Id) 44 .HasIdentityOptions(startValue: 1); 45 46 modelBuilder.Entity<PharmacyHeadMedicine>() 47 .Property(x => x.Id) 48 .HasIdentityOptions(startValue: 1); 49 50 modelBuilder.Entity<RequestPharmacyHead>() 51 .Property(x => x.Id) 52 .HasIdentityOptions(startValue: 1); 53 54 modelBuilder.Entity<User>() 55 .Property(x => x.Id) 56 .HasIdentityOptions(startValue: 1); 31 57 32 58 modelBuilder.Entity<PharmacyHeadMedicine>() … … 47 73 .HasForeignKey(k => k.PheadId); 48 74 49 /*50 modelBuilder.Entity<CarDetails>()51 .ToTable("CarDetails");52 75 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 76 66 77 base.OnModelCreating(modelBuilder); -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r8b13eb2 r8e74e2f 50 50 EditedPHead.PHMedicineList = pharmacyHead.PHMedicineList; 51 51 //_context.Entry<PharmacyHead>(Phead).State = EntityState.Detached; 52 Phead = EditedPHead;52 //Phead = EditedPHead; 53 53 await _context.SaveChangesAsync(); 54 54 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r8b13eb2 r8e74e2f 45 45 var Medicines = await _context.Medicines.Select(x => new Medicine 46 46 { 47 Id = x.Id, 47 48 Name = x.Name, 48 49 Strength = x.Strength, … … 268 269 return phmeds; 269 270 } 271 272 public async Task AddUser(User user) 273 { 274 await _context.Users.AddAsync(user); 275 await _context.SaveChangesAsync(); 276 } 270 277 } 271 278 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
r8b13eb2 r8e74e2f 45 45 User GetRole(string userName); 46 46 ICollection<PharmacyHeadMedicine> GetPHMedicines(string email); 47 Task AddUser(User user); 47 48 } 48 49 } -
FarmatikoData/Migrations/20201115222819_InitialMigration.Designer.cs
r8b13eb2 r8e74e2f 11 11 { 12 12 [DbContext(typeof(FarmatikoDataContext))] 13 [Migration("2020111 1183247_InitialMigration")]13 [Migration("20201115222819_InitialMigration")] 14 14 partial class InitialMigration 15 15 { … … 18 18 #pragma warning disable 612, 618 19 19 modelBuilder 20 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn)21 .HasAnnotation("ProductVersion", "3.1. 6")20 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) 21 .HasAnnotation("ProductVersion", "3.1.10") 22 22 .HasAnnotation("Relational:MaxIdentifierLength", 63); 23 23 … … 27 27 .ValueGeneratedOnAdd() 28 28 .HasColumnType("integer") 29 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn);29 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 30 30 31 31 b.Property<string>("Address") … … 67 67 .ValueGeneratedOnAdd() 68 68 .HasColumnType("integer") 69 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn);69 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 70 70 71 71 b.Property<string>("Branch") … … 101 101 .ValueGeneratedOnAdd() 102 102 .HasColumnType("integer") 103 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 103 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 104 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 104 105 105 106 b.Property<DateTime>("CreatedOn") … … 149 150 .ValueGeneratedOnAdd() 150 151 .HasColumnType("integer") 151 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn);152 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 152 153 153 154 b.Property<long>("ActiveGlobal") … … 192 193 .ValueGeneratedOnAdd() 193 194 .HasColumnType("integer") 194 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 195 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 196 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 195 197 196 198 b.Property<string>("Address") … … 230 232 .ValueGeneratedOnAdd() 231 233 .HasColumnType("integer") 232 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 234 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 235 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 233 236 234 237 b.Property<DateTime>("CreatedOn") … … 270 273 271 274 b.Property<int>("Id") 272 .HasColumnType("integer"); 275 .HasColumnType("integer") 276 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'"); 273 277 274 278 b.HasKey("PheadId", "MedicineId"); … … 284 288 .ValueGeneratedOnAdd() 285 289 .HasColumnType("integer") 286 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 290 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 291 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 287 292 288 293 b.Property<DateTime>("CreatedOn") … … 312 317 .ValueGeneratedOnAdd() 313 318 .HasColumnType("integer") 314 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 319 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 320 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 315 321 316 322 b.Property<DateTime>("CreatedOn") … … 321 327 322 328 b.Property<string>("Email") 323 .HasColumnType("text"); 324 325 b.Property<string>("Name") 329 .IsRequired() 330 .HasColumnType("text"); 331 332 b.Property<string>("Name") 333 .IsRequired() 326 334 .HasColumnType("text"); 327 335 328 336 b.Property<string>("Password") 337 .IsRequired() 329 338 .HasColumnType("text"); 330 339 -
FarmatikoData/Migrations/20201115222819_InitialMigration.cs
r8b13eb2 r8e74e2f 14 14 { 15 15 Id = table.Column<int>(nullable: false) 16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),17 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: 16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 17 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql:"now()"), 18 18 DeletedOn = table.Column<DateTime>(nullable: true), 19 19 Name = table.Column<string>(nullable: false), … … 34 34 { 35 35 Id = table.Column<int>(nullable: false) 36 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),36 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 37 37 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 38 38 DeletedOn = table.Column<DateTime>(nullable: true), … … 56 56 { 57 57 Id = table.Column<int>(nullable: false) 58 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),58 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 59 59 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 60 60 DeletedOn = table.Column<DateTime>(nullable: true), … … 73 73 { 74 74 Id = table.Column<int>(nullable: false) 75 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),75 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 76 76 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 77 77 DeletedOn = table.Column<DateTime>(nullable: true), … … 91 91 { 92 92 Id = table.Column<int>(nullable: false) 93 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),93 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 94 94 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 95 95 DeletedOn = table.Column<DateTime>(nullable: true), … … 115 115 { 116 116 Id = table.Column<int>(nullable: false) 117 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),117 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 118 118 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 119 119 DeletedOn = table.Column<DateTime>(nullable: true), … … 143 143 { 144 144 Id = table.Column<int>(nullable: false) 145 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),146 CreatedOn = table.Column<DateTime>(nullable: false ),145 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 146 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 147 147 DeletedOn = table.Column<DateTime>(nullable: true), 148 148 Name = table.Column<string>(nullable: false), … … 195 195 { 196 196 Id = table.Column<int>(nullable: false) 197 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn),197 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 198 198 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 199 199 DeletedOn = table.Column<DateTime>(nullable: true), -
FarmatikoData/Migrations/FarmatikoDataContextModelSnapshot.cs
r8b13eb2 r8e74e2f 16 16 #pragma warning disable 612, 618 17 17 modelBuilder 18 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn)19 .HasAnnotation("ProductVersion", "3.1. 6")18 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) 19 .HasAnnotation("ProductVersion", "3.1.10") 20 20 .HasAnnotation("Relational:MaxIdentifierLength", 63); 21 21 … … 25 25 .ValueGeneratedOnAdd() 26 26 .HasColumnType("integer") 27 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn);27 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 28 28 29 29 b.Property<string>("Address") … … 65 65 .ValueGeneratedOnAdd() 66 66 .HasColumnType("integer") 67 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn);67 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 68 68 69 69 b.Property<string>("Branch") … … 99 99 .ValueGeneratedOnAdd() 100 100 .HasColumnType("integer") 101 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 101 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 102 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 102 103 103 104 b.Property<DateTime>("CreatedOn") … … 147 148 .ValueGeneratedOnAdd() 148 149 .HasColumnType("integer") 149 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy. IdentityByDefaultColumn);150 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 150 151 151 152 b.Property<long>("ActiveGlobal") … … 190 191 .ValueGeneratedOnAdd() 191 192 .HasColumnType("integer") 192 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 193 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 194 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 193 195 194 196 b.Property<string>("Address") … … 228 230 .ValueGeneratedOnAdd() 229 231 .HasColumnType("integer") 230 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 232 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 233 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 231 234 232 235 b.Property<DateTime>("CreatedOn") … … 268 271 269 272 b.Property<int>("Id") 270 .HasColumnType("integer"); 273 .HasColumnType("integer") 274 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'"); 271 275 272 276 b.HasKey("PheadId", "MedicineId"); … … 282 286 .ValueGeneratedOnAdd() 283 287 .HasColumnType("integer") 284 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 288 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 289 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 285 290 286 291 b.Property<DateTime>("CreatedOn") … … 310 315 .ValueGeneratedOnAdd() 311 316 .HasColumnType("integer") 312 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 317 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 318 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 313 319 314 320 b.Property<DateTime>("CreatedOn") … … 319 325 320 326 b.Property<string>("Email") 321 .HasColumnType("text"); 322 323 b.Property<string>("Name") 327 .IsRequired() 328 .HasColumnType("text"); 329 330 b.Property<string>("Name") 331 .IsRequired() 324 332 .HasColumnType("text"); 325 333 326 334 b.Property<string>("Password") 335 .IsRequired() 327 336 .HasColumnType("text"); 328 337 -
FarmatikoData/Models/PharmacyHead.cs
r8b13eb2 r8e74e2f 22 22 public string Password { get; set; } 23 23 24 25 24 [JsonProperty("PharmacyMedicines")] 26 25 public List<Medicine> MedicineList { get; set; } -
FarmatikoData/Models/User.cs
r8b13eb2 r8e74e2f 2 2 using System; 3 3 using System.Collections.Generic; 4 using System.ComponentModel.DataAnnotations; 4 5 using System.Text; 5 6 … … 13 14 PharmacyHead 14 15 } 16 [Required] 15 17 public string Name { get; set; } 18 [Required] 16 19 public string Email { get; set; } 20 [Required] 17 21 public string Password { get; set; } 18 22 public Role UserRole { get; set; } -
FarmatikoServices/Services/PHService.cs
r8b13eb2 r8e74e2f 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 using System.Text;8 7 using System.Threading.Tasks; 9 8 … … 64 63 var phead = _iPHRepo.GetPharmacyHead(pharmacyHead.Email); 65 64 66 if (pharmacyHead.PharmaciesList.Count() == 0)67 pharmacyHead.PharmaciesList = null; 65 /*if (pharmacyHead.PharmaciesList.Count() == 0) 66 pharmacyHead.PharmaciesList = null;*/ 68 67 69 68 70 69 phead.PHMedicineList = _repository.GetPHMedicines(phead.Email); 71 70 72 if (phead.MedicineList != pharmacyHead.MedicineList || phead != pharmacyHead)71 if (phead.MedicineList != pharmacyHead.MedicineList) 73 72 { 74 73 phead.MedicineList = pharmacyHead.MedicineList; … … 83 82 return; 84 83 } 85 foreach (var med in phead.MedicineList)86 {87 med.Id++;88 var PHMObj = phead.PHMedicineList.Select(x => new PharmacyHeadMedicine84 List<PharmacyHeadMedicine> PHMList = new List<PharmacyHeadMedicine>(); 85 if (phead.PHMedicineList == pharmacyHead.PHMedicineList) 86 { 87 foreach (var med in phead.MedicineList) 89 88 { 90 PheadId = x.PheadId, 91 Head = x.Head, 92 MedicineId = x.MedicineId, 93 Medicine = x.Medicine 94 }).Where(x => x.MedicineId == med.Id).Single(); 95 list.Add(PHMObj); 89 //list = phead.PHMedicineList.ToList(); 90 91 var PHMObj = phead.PHMedicineList.Select(x => new PharmacyHeadMedicine 92 { 93 Id = x.Id, 94 PheadId = x.PheadId, 95 Head = x.Head, 96 MedicineId = x.MedicineId, 97 Medicine = x.Medicine 98 }).Where(x => x.MedicineId == med.Id).Single(); 99 if (PHMObj == null || PHMObj == default) 100 break; 101 if (PHMObj.MedicineId == med.Id) 102 list.Add(PHMObj); 103 104 } 105 106 phead.PHMedicineList = list; 96 107 } 97 108 98 phead.PHMedicineList = list;99 100 109 await _iPHRepo.UpdatePharmacyHead(phead); 110 } 111 else if (!phead.Equals(pharmacyHead)) 112 { 113 await _iPHRepo.UpdatePharmacyHead(pharmacyHead); 101 114 } 102 115 else throw new Exception("Cannot update pharmacy head since there was no changes."); … … 154 167 if (user.UserRole.ToString().Equals("Admin")) 155 168 { 156 var Admin = new 169 var Admin = new PharmacyHead() 157 170 { 158 171 Id = user.Id, 159 172 Email = user.Email, 160 173 Name = user.Name, 161 Passwd = user.Password, 162 MedicineList = PHMedicines, 174 Password = user.Password, 163 175 PharmaciesList = Phead.PharmaciesList 164 176 }; … … 167 179 } 168 180 169 if (PheadPharms.Count() > 0 )170 Phead. MedicineList = PHMedicineList;181 if (PheadPharms.Count() > 0 || PheadPharms != null) 182 Phead.PharmaciesList = PheadPharms; 171 183 else Phead.PharmaciesList = pharmacies; 172 184 173 if (Phead.PHMedicineList.Count() > 0 )185 if (Phead.PHMedicineList.Count() > 0 || Phead.PHMedicineList != null) 174 186 { 175 187 foreach (var med in Medicines) 176 188 { 177 var PHMObj = Phead.PHMedicineList.Select(x => new PharmacyHeadMedicine 189 190 var PHMObj = Phead.PHMedicineList.Where(x => x.MedicineId == med.Id).SingleOrDefault(); 191 if (PHMObj == null) 178 192 { 179 PheadId = x.PheadId, 180 Head = x.Head, 181 MedicineId = x.MedicineId, 182 Medicine = x.Medicine 183 }).Where(x => x.MedicineId == med.Id).SingleOrDefault(); 184 if (PHMObj == null || PHMObj == default) 185 break; 193 continue; 194 } 195 var phm = Phead.MedicineList; 186 196 if (PHMObj.MedicineId == med.Id) 187 197 { 188 Medicine medicine = new Medicine(med.Name, med.Strength, med.Form, med.WayOfIssuing, med.Manufacturer, med.Price, med.Packaging); 198 var medicine = new Medicine() 199 { 200 Id = med.Id, 201 Name = med.Name, 202 Strength = med.Strength, 203 Form = med.Form, 204 WayOfIssuing = med.WayOfIssuing, 205 Manufacturer = med.Manufacturer, 206 Price = med.Price, 207 Packaging = med.Packaging 208 }; 189 209 PHMedicineList.Add(medicine); 190 210 } -
FarmatikoServices/Services/Service.cs
r8b13eb2 r8e74e2f 128 128 129 129 // Ovaa kontrola ja ima samo admin 130 public User MakeUser(PharmacyHead head) 131 { 132 var users = _repository.GetUsers(); 133 134 User user = new User() 135 { 136 Name = head.Name, 137 Password = head.Password, 138 Email = head.Email, 139 UserRole = User.Role.PharmacyHead 140 }; 141 return user; 142 } 130 143 public async Task AddPharmacyHead(PharmacyHead pharmacyHead) 131 144 { 132 145 if (pharmacyHead != null) 133 146 { 134 /*var Medicines = await _repository.GetMedicinesAsync(); 135 foreach (var med in Medicines) 136 { 137 pharmacyHead.MedicineList.Add(med); 138 }*/ 139 147 var user = MakeUser(pharmacyHead); 148 await _repository.AddUser(user); 140 149 await _repository.AddPharmacyHead(pharmacyHead); 141 150 }
Note:
See TracChangeset
for help on using the changeset viewer.