Changeset d23bf72 for FarmatikoData
- Timestamp:
- 11/05/20 06:57:35 (4 years ago)
- Branches:
- master
- Children:
- afc9a9a
- Parents:
- 1f4846d
- Location:
- FarmatikoData
- Files:
-
- 3 added
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoData.csproj
r1f4846d rd23bf72 4 4 <TargetFramework>netcoreapp3.1</TargetFramework> 5 5 </PropertyGroup> 6 7 <ItemGroup>8 <Compile Remove="Migrations\20200729091456_Second migration.cs" />9 <Compile Remove="Migrations\20200729091456_Second migration.Designer.cs" />10 <Compile Remove="Migrations\20200729091727_Second Migration.cs" />11 <Compile Remove="Migrations\20200729091727_Second Migration.Designer.cs" />12 <Compile Remove="Migrations\20200729101719_Third Migration.cs" />13 <Compile Remove="Migrations\20200729101719_Third Migration.Designer.cs" />14 </ItemGroup>15 6 16 7 <ItemGroup> -
FarmatikoData/FarmatikoDataContext.cs
r1f4846d rd23bf72 17 17 public virtual DbSet<MedicineList> MedicineLists { get; set; } 18 18 public virtual DbSet<RequestPharmacyHead> PHRequests { get; set; } 19 public virtual DbSet<User> Users { get; set; } 19 20 } 20 21 } -
FarmatikoData/FarmatikoRepo/AdminRepo.cs
r1f4846d rd23bf72 31 31 } 32 32 //POST 33 public void RemoveClaimRequest( RequestPharmacyHead req)33 public void RemoveClaimRequest(int Id) 34 34 { 35 var req = _context.PHRequests.Where(x => x.Id == Id).FirstOrDefault(); 35 36 _context.PHRequests.Remove(req); 36 37 _context.SaveChanges(); -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r1f4846d rd23bf72 71 71 await _context.SaveChangesAsync(); 72 72 } 73 74 public PharmacyHead GetPharmacyHeadByUserName(string userName) 75 { 76 return _context.PharmacyHeads 77 .Where(x => x.Email.Equals(userName)) 78 .FirstOrDefault(); 79 } 73 80 } 74 81 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r1f4846d rd23bf72 19 19 public async Task<IEnumerable<HealthcareWorker>> GetAllWorkers() 20 20 { 21 var Workers = await Task.Run(() => _context.HealthcareWorkers.Take(10));21 var Workers = await _context.HealthcareWorkers.Take(5).ToListAsync(); 22 22 return Workers; 23 23 } … … 25 25 public async Task<IEnumerable<HealthFacility>> GetFacilities() 26 26 { 27 var Facilities = await Task.Run(() => _context.HealthFacilities.Take(10));27 var Facilities = await _context.HealthFacilities.Take(5).ToListAsync(); 28 28 return Facilities; 29 29 } … … 43 43 public async Task<IEnumerable<Medicine>> GetMedicines() 44 44 { 45 var Medicines = await Task.Run(() => _context.Medicines.Take(10));45 var Medicines = await _context.Medicines.Take(3).ToListAsync(); 46 46 return Medicines; 47 47 } … … 49 49 public async Task<Pandemic> GetPandemic() 50 50 { 51 var Pandemic = await Task.Run(() => _context.Pandemics.FirstOrDefault());51 var Pandemic = await _context.Pandemics.FirstOrDefaultAsync(); 52 52 return Pandemic; 53 53 } … … 55 55 public async Task<IEnumerable<Pharmacy>> GetPharmacies() 56 56 { 57 var Pharmacies = await Task.Run(() => _context.Pharmacies.Take(10));57 var Pharmacies = await _context.Pharmacies.Take(5).ToListAsync(); 58 58 return Pharmacies; 59 59 } … … 73 73 public async Task<IEnumerable<HealthFacility>> SearchFacilities(string query) 74 74 { 75 var SearchQuery = await Task.Run(() =>_context.HealthFacilities76 .Where(x => x.Name. Equals(query))77 .OrderBy(x => x.Name) );75 var SearchQuery = await _context.HealthFacilities 76 .Where(x => x.Name.Contains(query)) 77 .OrderBy(x => x.Name).Take(3).ToListAsync(); 78 78 79 79 return SearchQuery; … … 82 82 public async Task<IEnumerable<Medicine>> SearchMedicines(string query) 83 83 { 84 var SearchQuery = await Task.Run(() =>_context.Medicines85 .Where(x => x.Name. Equals(query))86 .OrderBy(x => x.Name) );84 var SearchQuery = await _context.Medicines 85 .Where(x => x.Name.Contains(query)) 86 .OrderBy(x => x.Name).Take(5).ToListAsync(); 87 87 88 88 return SearchQuery; … … 91 91 public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string query) 92 92 { 93 var SearchQuery = await Task.Run(() => _context.Pharmacies94 .Where(x => x.Name. Equals(query))95 .OrderBy(x => x.Name) );93 var SearchQuery = await _context.Pharmacies.Take(5) 94 .Where(x => x.Name.Contains(query)) 95 .OrderBy(x => x.Name).Take(5).ToListAsync(); 96 96 97 97 return SearchQuery; … … 100 100 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query) 101 101 { 102 var SearchQuery = await Task.Run(() => _context.HealthcareWorkers103 .Where(x => x.Name. Equals(query))104 .OrderBy(x => x.Name) );105 106 return SearchQuery; 107 } 108 public async Task<HealthFacility>GetFacilityJSON(string healthFacility)109 { 110 var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault());102 var SearchQuery = await _context.HealthcareWorkers.Take(5) 103 .Where(x => x.Name.Contains(query)) 104 .OrderBy(x => x.Name).Take(5).ToListAsync(); 105 106 return SearchQuery; 107 } 108 public HealthFacility GetFacilityJSON(string healthFacility) 109 { 110 var Facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault(); 111 111 return Facility; 112 112 } … … 116 116 public async Task AddWorker(HealthcareWorker Worker) 117 117 { 118 await Task.Run(() => _context.HealthcareWorkers.Add(Worker));119 await _context.SaveChangesAsync();118 await _context.HealthcareWorkers.AddAsync(Worker); 119 _context.SaveChanges(); 120 120 } 121 121 122 122 public async Task AddFacility(HealthFacility healthFacility) 123 123 { 124 await Task.Run(() => _context.HealthFacilities.Add(healthFacility));125 await _context.SaveChangesAsync();124 await _context.HealthFacilities.AddAsync(healthFacility); 125 _context.SaveChanges(); 126 126 } 127 127 128 128 public async Task AddPharmacy(Pharmacy pharmacy) 129 129 { 130 await Task.Run(() => _context.Pharmacies.Add(pharmacy));131 await _context.SaveChangesAsync();130 await _context.Pharmacies.AddAsync(pharmacy); 131 _context.SaveChanges(); 132 132 } 133 133 134 134 public async Task AddPharmacyHead(PharmacyHead pharmacyHead) 135 135 { 136 await Task.Run(() => _context.PharmacyHeads.Add(pharmacyHead));137 await _context.SaveChangesAsync();136 await _context.PharmacyHeads.AddAsync(pharmacyHead); 137 _context.SaveChanges(); 138 138 } 139 139 140 140 public async Task AddMedicines(Medicine medicine) 141 141 { 142 await Task.Run(() => _context.Medicines.Add(medicine));143 await _context.SaveChangesAsync();142 await _context.Medicines.AddAsync(medicine); 143 _context.SaveChanges(); 144 144 } 145 145 146 146 public async Task AddPandemic(Pandemic pandemic) 147 147 { 148 await Task.Run(() => _context.Pandemics.Add(pandemic));149 await _context.SaveChangesAsync();148 var pand = await _context.Pandemics.AddAsync(pandemic); 149 _context.SaveChanges(); 150 150 } 151 151 152 152 public async Task UpdateFacility(HealthFacility healthFacility) 153 153 { 154 var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Id == healthFacility.Id).FirstOrDefault());154 var Facility = await _context.HealthFacilities.Where(x => x.Id == healthFacility.Id).FirstOrDefaultAsync(); 155 155 Facility.Address = healthFacility.Address; 156 156 Facility.Email = healthFacility.Email; … … 159 159 Facility.Phone = healthFacility.Phone; 160 160 Facility.Type = healthFacility.Type; 161 await _context.SaveChangesAsync();161 _context.SaveChanges(); 162 162 } 163 163 … … 165 165 { 166 166 await Task.Run(() => _context.Medicines.Remove(medicine)); 167 await _context.SaveChangesAsync();167 _context.SaveChanges(); 168 168 } 169 169 170 170 public async Task UpdatePandemic(Pandemic pandemic) 171 171 { 172 var Pandemic = await Task.Run(() => _context.Pandemics.Where(x => x.Id == pandemic.Id).FirstOrDefault());172 var Pandemic = await _context.Pandemics.Where(x => x.Id == pandemic.Id).FirstOrDefaultAsync(); 173 173 Pandemic.ActiveGlobal = pandemic.ActiveGlobal; 174 174 Pandemic.ActiveMK = pandemic.ActiveMK; … … 179 179 Pandemic.TotalGlobal = pandemic.TotalGlobal; 180 180 Pandemic.TotalMK = pandemic.TotalMK; 181 await _context.SaveChangesAsync();181 _context.SaveChanges(); 182 182 } 183 183 … … 185 185 { 186 186 await Task.Run(() => _context.Pharmacies.Remove(pharmacy)); 187 await _context.SaveChangesAsync();187 _context.SaveChanges(); 188 188 } 189 189 //not impl … … 195 195 public async Task UpadatePharmacy(Pharmacy pharmacy) 196 196 { 197 var Pharmacy = await Task.Run(() => _context.Pharmacies.Where(x => x.Id == pharmacy.Id).FirstOrDefault());197 var Pharmacy = await _context.Pharmacies.Where(x => x.Id == pharmacy.Id).FirstOrDefaultAsync(); 198 198 Pharmacy.Name = pharmacy.Name; 199 199 Pharmacy.Location = pharmacy.Location; 200 200 Pharmacy.WorkAllTime = pharmacy.WorkAllTime; 201 201 Pharmacy.Address = pharmacy.Address; 202 await _context.SaveChangesAsync();202 _context.SaveChanges(); 203 203 } 204 204 //ke vidime … … 212 212 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 213 213 PHead.DeletedOn = DateTime.UtcNow; 214 await _context.SaveChangesAsync(); 215 } 216 214 _context.SaveChanges(); 215 } 216 217 public IDictionary<string, User> GetUsers() 218 { 219 var users = _context.Users.ToDictionary(x => x.Email, x => new User 220 { 221 Id = x.Id, 222 Name = x.Name, 223 Email = x.Email, 224 Password = x.Password, 225 UserRole = x.UserRole 226 }); 227 return users; 228 } 217 229 } 218 230 } -
FarmatikoData/FarmatikoRepoInterfaces/IAdminRepo.cs
r1f4846d rd23bf72 12 12 Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests(); 13 13 Task<IEnumerable<PharmacyHead>> GetPharmacyHeads(); 14 void RemoveClaimRequest( RequestPharmacyHead req);14 void RemoveClaimRequest(int Id); 15 15 } 16 16 } -
FarmatikoData/FarmatikoRepoInterfaces/IPHRepo.cs
r1f4846d rd23bf72 17 17 Task Remove(PharmacyHead phead); 18 18 Task RemoveClaimingRequest(int id); 19 PharmacyHead GetPharmacyHeadByUserName(string userName); 19 20 } 20 21 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
r1f4846d rd23bf72 24 24 Task<IEnumerable<Pharmacy>> SearchPharmacies(string query); 25 25 Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query); 26 Task<HealthFacility> GetFacilityJSON(string healthFacility); 26 HealthFacility GetFacilityJSON(string healthFacility); 27 IDictionary<string, User> GetUsers(); 27 28 28 29 //POST -
FarmatikoData/Migrations/20201104230858_InitialMigration.cs
r1f4846d rd23bf72 5 5 namespace FarmatikoData.Migrations 6 6 { 7 public partial class Initial migration : Migration7 public partial class InitialMigration : Migration 8 8 { 9 9 protected override void Up(MigrationBuilder migrationBuilder) … … 15 15 Id = table.Column<int>(nullable: false) 16 16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 17 CreatedOn = table.Column<DateTime>(nullable: false , defaultValueSql: "now()"),17 CreatedOn = table.Column<DateTime>(nullable: false), 18 18 DeletedOn = table.Column<DateTime>(nullable: true), 19 19 Name = table.Column<string>(nullable: false), … … 24 24 Phone = table.Column<string>(nullable: true) 25 25 }, 26 constraints: table => 26 constraints: table => 27 27 { 28 28 table.PrimaryKey("PK_HealthFacilities", x => x.Id); … … 30 30 31 31 migrationBuilder.CreateTable( 32 name: "Medicines", 33 columns: table => new 34 { 35 Id = table.Column<int>(nullable: false) 36 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 37 CreatedOn = table.Column<DateTime>(nullable: false), 38 DeletedOn = table.Column<DateTime>(nullable: true), 39 Name = table.Column<string>(nullable: false), 40 Strength = table.Column<string>(nullable: false), 41 Form = table.Column<string>(nullable: true), 42 WayOfIssuing = table.Column<string>(nullable: false), 43 Manufacturer = table.Column<string>(nullable: false), 44 Price = table.Column<float>(nullable: false), 45 Packaging = table.Column<string>(nullable: true) 46 }, 47 constraints: table => 48 { 49 table.PrimaryKey("PK_Medicines", x => x.Id); 50 }); 51 52 migrationBuilder.CreateTable( 32 53 name: "Pandemics", 33 54 columns: table => new … … 35 56 Id = table.Column<int>(nullable: false) 36 57 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 37 CreatedOn = table.Column<DateTime>(nullable: false , defaultValueSql: "now()"),38 DeletedOn = table.Column<DateTime>(nullable: true), 39 Name = table.Column<string>(nullable: true),58 CreatedOn = table.Column<DateTime>(nullable: false), 59 DeletedOn = table.Column<DateTime>(nullable: true), 60 Name = table.Column<string>(nullable: false), 40 61 TotalMK = table.Column<int>(nullable: false), 41 62 ActiveMK = table.Column<int>(nullable: false), 42 63 DeathsMK = table.Column<int>(nullable: false), 43 64 NewMK = table.Column<int>(nullable: false), 44 TotalGlobal = table.Column< int>(nullable: false),45 DeathsGlobal = table.Column< int>(nullable: false),46 ActiveGlobal = table.Column< int>(nullable: false)65 TotalGlobal = table.Column<long>(nullable: false), 66 DeathsGlobal = table.Column<long>(nullable: false), 67 ActiveGlobal = table.Column<long>(nullable: false) 47 68 }, 48 69 constraints: table => … … 52 73 53 74 migrationBuilder.CreateTable( 75 name: "PharmacyHeads", 76 columns: table => new 77 { 78 Id = table.Column<int>(nullable: false) 79 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 80 CreatedOn = table.Column<DateTime>(nullable: false), 81 DeletedOn = table.Column<DateTime>(nullable: true), 82 Email = table.Column<string>(nullable: false), 83 Name = table.Column<string>(nullable: false), 84 Password = table.Column<string>(nullable: false) 85 }, 86 constraints: table => 87 { 88 table.PrimaryKey("PK_PharmacyHeads", x => x.Id); 89 }); 90 91 migrationBuilder.CreateTable( 92 name: "Users", 93 columns: table => new 94 { 95 Id = table.Column<int>(nullable: false) 96 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 97 CreatedOn = table.Column<DateTime>(nullable: false), 98 DeletedOn = table.Column<DateTime>(nullable: true), 99 Name = table.Column<string>(nullable: true), 100 Email = table.Column<string>(nullable: true), 101 Password = table.Column<string>(nullable: true), 102 UserRole = table.Column<int>(nullable: false) 103 }, 104 constraints: table => 105 { 106 table.PrimaryKey("PK_Users", x => x.Id); 107 }); 108 109 migrationBuilder.CreateTable( 54 110 name: "HealthcareWorkers", 55 111 columns: table => new … … 57 113 Id = table.Column<int>(nullable: false) 58 114 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 59 CreatedOn = table.Column<DateTime>(nullable: false , defaultValueSql: "now()"),115 CreatedOn = table.Column<DateTime>(nullable: false), 60 116 DeletedOn = table.Column<DateTime>(nullable: true), 61 117 Name = table.Column<string>(nullable: false), … … 76 132 77 133 migrationBuilder.CreateTable( 78 name: "Medicines",79 columns: table => new80 {81 Id = table.Column<int>(nullable: false)82 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),83 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),84 DeletedOn = table.Column<DateTime>(nullable: true),85 Name = table.Column<string>(nullable: true),86 Strength = table.Column<string>(nullable: true),87 Form = table.Column<string>(nullable: true),88 WayOfIssuing = table.Column<string>(nullable: true),89 Manufacturer = table.Column<string>(nullable: true),90 Price = table.Column<float>(nullable: false),91 Packaging = table.Column<string>(nullable: true),92 MedicineListId = table.Column<int>(nullable: true)93 },94 constraints: table =>95 {96 table.PrimaryKey("PK_Medicines", x => x.Id);97 });98 99 migrationBuilder.CreateTable(100 name: "PharmacyHeads",101 columns: table => new102 {103 Id = table.Column<int>(nullable: false)104 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),105 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),106 DeletedOn = table.Column<DateTime>(nullable: true),107 PharmacyMedicinesId = table.Column<int>(nullable: true),108 PharmacyId = table.Column<int>(nullable: true),109 Email = table.Column<string>(nullable: true),110 Name = table.Column<string>(nullable: true),111 Password = table.Column<string>(nullable: true)112 },113 constraints: table =>114 {115 table.PrimaryKey("PK_PharmacyHeads", x => x.Id);116 });117 118 migrationBuilder.CreateTable(119 134 name: "MedicineLists", 120 135 columns: table => new … … 122 137 Id = table.Column<int>(nullable: false) 123 138 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 124 CreatedOn = table.Column<DateTime>(nullable: false , defaultValueSql: "now()"),125 DeletedOn = table.Column<DateTime>(nullable: true), 126 Medicine sId = table.Column<int>(nullable: true),139 CreatedOn = table.Column<DateTime>(nullable: false), 140 DeletedOn = table.Column<DateTime>(nullable: true), 141 MedicineId = table.Column<int>(nullable: false), 127 142 HasMedicine = table.Column<bool>(nullable: false), 128 143 PharmacyHeadId = table.Column<int>(nullable: true) … … 132 147 table.PrimaryKey("PK_MedicineLists", x => x.Id); 133 148 table.ForeignKey( 134 name: "FK_MedicineLists_Medicines_Medicine sId",135 column: x => x.Medicine sId,149 name: "FK_MedicineLists_Medicines_MedicineId", 150 column: x => x.MedicineId, 136 151 principalTable: "Medicines", 137 152 principalColumn: "Id", 138 onDelete: ReferentialAction. Restrict);153 onDelete: ReferentialAction.Cascade); 139 154 table.ForeignKey( 140 155 name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId", … … 151 166 Id = table.Column<int>(nullable: false) 152 167 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 153 CreatedOn = table.Column<DateTime>(nullable: false , defaultValueSql: "now()"),154 DeletedOn = table.Column<DateTime>(nullable: true), 155 Name = table.Column<string>(nullable: true),156 Location = table.Column<string>(nullable: true),157 Address = table.Column<string>(nullable: true),168 CreatedOn = table.Column<DateTime>(nullable: false), 169 DeletedOn = table.Column<DateTime>(nullable: true), 170 Name = table.Column<string>(nullable: false), 171 Location = table.Column<string>(nullable: false), 172 Address = table.Column<string>(nullable: false), 158 173 WorkAllTime = table.Column<bool>(nullable: false), 159 174 PharmacyHeadId = table.Column<int>(nullable: true) … … 170 185 }); 171 186 187 migrationBuilder.CreateTable( 188 name: "PHRequests", 189 columns: table => new 190 { 191 Id = table.Column<int>(nullable: false) 192 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 193 CreatedOn = table.Column<DateTime>(nullable: false), 194 DeletedOn = table.Column<DateTime>(nullable: true), 195 HeadId = table.Column<int>(nullable: false), 196 PharmacyId = table.Column<int>(nullable: false) 197 }, 198 constraints: table => 199 { 200 table.PrimaryKey("PK_PHRequests", x => x.Id); 201 table.ForeignKey( 202 name: "FK_PHRequests_PharmacyHeads_HeadId", 203 column: x => x.HeadId, 204 principalTable: "PharmacyHeads", 205 principalColumn: "Id", 206 onDelete: ReferentialAction.Cascade); 207 table.ForeignKey( 208 name: "FK_PHRequests_Pharmacies_PharmacyId", 209 column: x => x.PharmacyId, 210 principalTable: "Pharmacies", 211 principalColumn: "Id", 212 onDelete: ReferentialAction.Cascade); 213 }); 214 172 215 migrationBuilder.CreateIndex( 173 216 name: "IX_HealthcareWorkers_FacilityId", … … 176 219 177 220 migrationBuilder.CreateIndex( 178 name: "IX_MedicineLists_Medicine sId",221 name: "IX_MedicineLists_MedicineId", 179 222 table: "MedicineLists", 180 column: "Medicine sId");223 column: "MedicineId"); 181 224 182 225 migrationBuilder.CreateIndex( … … 186 229 187 230 migrationBuilder.CreateIndex( 188 name: "IX_Medicines_MedicineListId",189 table: "Medicines",190 column: "MedicineListId");191 192 migrationBuilder.CreateIndex(193 231 name: "IX_Pharmacies_PharmacyHeadId", 194 232 table: "Pharmacies", … … 196 234 197 235 migrationBuilder.CreateIndex( 198 name: "IX_PharmacyHeads_PharmacyId", 199 table: "PharmacyHeads", 236 name: "IX_PHRequests_HeadId", 237 table: "PHRequests", 238 column: "HeadId"); 239 240 migrationBuilder.CreateIndex( 241 name: "IX_PHRequests_PharmacyId", 242 table: "PHRequests", 200 243 column: "PharmacyId"); 201 202 migrationBuilder.CreateIndex(203 name: "IX_PharmacyHeads_PharmacyMedicinesId",204 table: "PharmacyHeads",205 column: "PharmacyMedicinesId");206 207 migrationBuilder.AddForeignKey(208 name: "FK_Medicines_MedicineLists_MedicineListId",209 table: "Medicines",210 column: "MedicineListId",211 principalTable: "MedicineLists",212 principalColumn: "Id",213 onDelete: ReferentialAction.Restrict);214 215 migrationBuilder.AddForeignKey(216 name: "FK_PharmacyHeads_MedicineLists_PharmacyMedicinesId",217 table: "PharmacyHeads",218 column: "PharmacyMedicinesId",219 principalTable: "MedicineLists",220 principalColumn: "Id",221 onDelete: ReferentialAction.Restrict);222 223 migrationBuilder.AddForeignKey(224 name: "FK_PharmacyHeads_Pharmacies_PharmacyId",225 table: "PharmacyHeads",226 column: "PharmacyId",227 principalTable: "Pharmacies",228 principalColumn: "Id",229 onDelete: ReferentialAction.Restrict);230 244 } 231 245 232 246 protected override void Down(MigrationBuilder migrationBuilder) 233 247 { 234 migrationBuilder.DropForeignKey(235 name: "FK_MedicineLists_Medicines_MedicinesId",236 table: "MedicineLists");237 238 migrationBuilder.DropForeignKey(239 name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId",240 table: "MedicineLists");241 242 migrationBuilder.DropForeignKey(243 name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId",244 table: "Pharmacies");245 246 248 migrationBuilder.DropTable( 247 249 name: "HealthcareWorkers"); 248 250 249 251 migrationBuilder.DropTable( 252 name: "MedicineLists"); 253 254 migrationBuilder.DropTable( 250 255 name: "Pandemics"); 251 256 252 257 migrationBuilder.DropTable( 258 name: "PHRequests"); 259 260 migrationBuilder.DropTable( 261 name: "Users"); 262 263 migrationBuilder.DropTable( 253 264 name: "HealthFacilities"); 254 265 … … 257 268 258 269 migrationBuilder.DropTable( 270 name: "Pharmacies"); 271 272 migrationBuilder.DropTable( 259 273 name: "PharmacyHeads"); 260 261 migrationBuilder.DropTable(262 name: "Pharmacies");263 264 migrationBuilder.DropTable(265 name: "MedicineLists");266 274 } 267 275 } -
FarmatikoData/Migrations/20201105055526_NewMigration.Designer.cs
r1f4846d rd23bf72 11 11 { 12 12 [DbContext(typeof(FarmatikoDataContext))] 13 [Migration("2020 0722131856_Initial migration")]14 partial class Initialmigration13 [Migration("20201105055526_NewMigration")] 14 partial class NewMigration 15 15 { 16 16 protected override void BuildTargetModel(ModelBuilder modelBuilder) … … 22 22 .HasAnnotation("Relational:MaxIdentifierLength", 63); 23 23 24 modelBuilder.Entity("FarmatikoData.Models.HealthFacilit ies", b =>24 modelBuilder.Entity("FarmatikoData.Models.HealthFacility", b => 25 25 { 26 26 b.Property<int>("Id") … … 36 36 .HasColumnType("timestamp without time zone"); 37 37 38 b.Property<DateTime >("DeletedOn")38 b.Property<DateTime?>("DeletedOn") 39 39 .HasColumnType("timestamp without time zone"); 40 40 … … 62 62 }); 63 63 64 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorker s", b =>64 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorker", b => 65 65 { 66 66 b.Property<int>("Id") … … 76 76 .HasColumnType("timestamp without time zone"); 77 77 78 b.Property<DateTime >("DeletedOn")78 b.Property<DateTime?>("DeletedOn") 79 79 .HasColumnType("timestamp without time zone"); 80 80 … … 106 106 .HasColumnType("timestamp without time zone"); 107 107 108 b.Property<DateTime >("DeletedOn")108 b.Property<DateTime?>("DeletedOn") 109 109 .HasColumnType("timestamp without time zone"); 110 110 … … 113 113 114 114 b.Property<string>("Manufacturer") 115 .HasColumnType("text"); 116 117 b.Property<int?>("MedicineListId") 118 .HasColumnType("integer"); 119 120 b.Property<string>("Name") 115 .IsRequired() 116 .HasColumnType("text"); 117 118 b.Property<string>("Name") 119 .IsRequired() 121 120 .HasColumnType("text"); 122 121 … … 128 127 129 128 b.Property<string>("Strength") 129 .IsRequired() 130 130 .HasColumnType("text"); 131 131 132 132 b.Property<string>("WayOfIssuing") 133 .HasColumnType("text"); 134 135 b.HasKey("Id"); 136 137 b.HasIndex("MedicineListId"); 133 .IsRequired() 134 .HasColumnType("text"); 135 136 b.HasKey("Id"); 138 137 139 138 b.ToTable("Medicines"); … … 150 149 .HasColumnType("timestamp without time zone"); 151 150 152 b.Property<DateTime >("DeletedOn")151 b.Property<DateTime?>("DeletedOn") 153 152 .HasColumnType("timestamp without time zone"); 154 153 … … 156 155 .HasColumnType("boolean"); 157 156 158 b.Property<int ?>("MedicinesId")157 b.Property<int>("MedicineId") 159 158 .HasColumnType("integer"); 160 159 … … 164 163 b.HasKey("Id"); 165 164 166 b.HasIndex("Medicine sId");165 b.HasIndex("MedicineId"); 167 166 168 167 b.HasIndex("PharmacyHeadId"); … … 178 177 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 179 178 180 b.Property< int>("ActiveGlobal")181 .HasColumnType(" integer");179 b.Property<long>("ActiveGlobal") 180 .HasColumnType("bigint"); 182 181 183 182 b.Property<int>("ActiveMK") … … 187 186 .HasColumnType("timestamp without time zone"); 188 187 189 b.Property< int>("DeathsGlobal")190 .HasColumnType(" integer");188 b.Property<long>("DeathsGlobal") 189 .HasColumnType("bigint"); 191 190 192 191 b.Property<int>("DeathsMK") 193 192 .HasColumnType("integer"); 194 193 195 b.Property<DateTime>("DeletedOn") 196 .HasColumnType("timestamp without time zone"); 197 198 b.Property<string>("Name") 194 b.Property<DateTime?>("DeletedOn") 195 .HasColumnType("timestamp without time zone"); 196 197 b.Property<string>("Name") 198 .IsRequired() 199 199 .HasColumnType("text"); 200 200 … … 202 202 .HasColumnType("integer"); 203 203 204 b.Property< int>("TotalGlobal")205 .HasColumnType(" integer");204 b.Property<long>("TotalGlobal") 205 .HasColumnType("bigint"); 206 206 207 207 b.Property<int>("TotalMK") … … 221 221 222 222 b.Property<string>("Address") 223 .HasColumnType("text"); 224 225 b.Property<DateTime>("CreatedOn") 226 .HasColumnType("timestamp without time zone"); 227 228 b.Property<DateTime>("DeletedOn") 223 .IsRequired() 224 .HasColumnType("text"); 225 226 b.Property<DateTime>("CreatedOn") 227 .HasColumnType("timestamp without time zone"); 228 229 b.Property<DateTime?>("DeletedOn") 229 230 .HasColumnType("timestamp without time zone"); 230 231 231 232 b.Property<string>("Location") 232 .HasColumnType("text"); 233 234 b.Property<string>("Name") 233 .IsRequired() 234 .HasColumnType("text"); 235 236 b.Property<string>("Name") 237 .IsRequired() 235 238 .HasColumnType("text"); 236 239 … … 258 261 .HasColumnType("timestamp without time zone"); 259 262 260 b.Property<DateTime >("DeletedOn")263 b.Property<DateTime?>("DeletedOn") 261 264 .HasColumnType("timestamp without time zone"); 262 265 263 266 b.Property<string>("Email") 264 .HasColumnType("text"); 265 266 b.Property<string>("Name") 267 .IsRequired() 268 .HasColumnType("text"); 269 270 b.Property<string>("Name") 271 .IsRequired() 267 272 .HasColumnType("text"); 268 273 269 274 b.Property<string>("Password") 270 .HasColumnType("text"); 271 272 b.Property<int?>("PharmacyId") 273 .HasColumnType("integer"); 274 275 b.Property<int?>("PharmacyMedicinesId") 276 .HasColumnType("integer"); 277 278 b.HasKey("Id"); 275 .IsRequired() 276 .HasColumnType("text"); 277 278 b.HasKey("Id"); 279 280 b.ToTable("PharmacyHeads"); 281 }); 282 283 modelBuilder.Entity("FarmatikoData.Models.RequestPharmacyHead", b => 284 { 285 b.Property<int>("Id") 286 .ValueGeneratedOnAdd() 287 .HasColumnType("integer") 288 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 289 290 b.Property<DateTime>("CreatedOn") 291 .HasColumnType("timestamp without time zone"); 292 293 b.Property<DateTime?>("DeletedOn") 294 .HasColumnType("timestamp without time zone"); 295 296 b.Property<int>("HeadId") 297 .HasColumnType("integer"); 298 299 b.Property<int>("PharmacyId") 300 .HasColumnType("integer"); 301 302 b.HasKey("Id"); 303 304 b.HasIndex("HeadId"); 279 305 280 306 b.HasIndex("PharmacyId"); 281 307 282 b.HasIndex("PharmacyMedicinesId"); 283 284 b.ToTable("PharmacyHeads"); 285 }); 286 287 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorkers", b => 288 { 289 b.HasOne("FarmatikoData.Models.HealthFacilities", "Facility") 308 b.ToTable("PHRequests"); 309 }); 310 311 modelBuilder.Entity("FarmatikoData.Models.User", b => 312 { 313 b.Property<int>("Id") 314 .ValueGeneratedOnAdd() 315 .HasColumnType("integer") 316 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 317 318 b.Property<DateTime>("CreatedOn") 319 .HasColumnType("timestamp without time zone"); 320 321 b.Property<DateTime?>("DeletedOn") 322 .HasColumnType("timestamp without time zone"); 323 324 b.Property<string>("Email") 325 .HasColumnType("text"); 326 327 b.Property<string>("Name") 328 .HasColumnType("text"); 329 330 b.Property<string>("Password") 331 .HasColumnType("text"); 332 333 b.Property<int>("UserRole") 334 .HasColumnType("integer"); 335 336 b.HasKey("Id"); 337 338 b.ToTable("Users"); 339 }); 340 341 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorker", b => 342 { 343 b.HasOne("FarmatikoData.Models.HealthFacility", "Facility") 290 344 .WithMany() 291 345 .HasForeignKey("FacilityId") … … 294 348 }); 295 349 296 modelBuilder.Entity("FarmatikoData.Models.Medicine", b =>297 {298 b.HasOne("FarmatikoData.Models.MedicineList", null)299 .WithMany("MedicinesList")300 .HasForeignKey("MedicineListId");301 });302 303 350 modelBuilder.Entity("FarmatikoData.Models.MedicineList", b => 304 351 { 305 b.HasOne("FarmatikoData.Models.Medicine", "Medicine s")352 b.HasOne("FarmatikoData.Models.Medicine", "Medicine") 306 353 .WithMany() 307 .HasForeignKey("MedicinesId"); 354 .HasForeignKey("MedicineId") 355 .OnDelete(DeleteBehavior.Cascade) 356 .IsRequired(); 308 357 309 358 b.HasOne("FarmatikoData.Models.PharmacyHead", null) … … 319 368 }); 320 369 321 modelBuilder.Entity("FarmatikoData.Models.PharmacyHead", b => 322 { 370 modelBuilder.Entity("FarmatikoData.Models.RequestPharmacyHead", b => 371 { 372 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head") 373 .WithMany() 374 .HasForeignKey("HeadId") 375 .OnDelete(DeleteBehavior.Cascade) 376 .IsRequired(); 377 323 378 b.HasOne("FarmatikoData.Models.Pharmacy", "Pharmacy") 324 379 .WithMany() 325 .HasForeignKey("PharmacyId"); 326 327 b.HasOne("FarmatikoData.Models.MedicineList", "PharmacyMedicines") 328 .WithMany() 329 .HasForeignKey("PharmacyMedicinesId"); 380 .HasForeignKey("PharmacyId") 381 .OnDelete(DeleteBehavior.Cascade) 382 .IsRequired(); 330 383 }); 331 384 #pragma warning restore 612, 618 -
FarmatikoData/Migrations/FarmatikoDataContextModelSnapshot.cs
r1f4846d rd23bf72 20 20 .HasAnnotation("Relational:MaxIdentifierLength", 63); 21 21 22 modelBuilder.Entity("FarmatikoData.Models.HealthFacilit ies", b =>22 modelBuilder.Entity("FarmatikoData.Models.HealthFacility", b => 23 23 { 24 24 b.Property<int>("Id") … … 60 60 }); 61 61 62 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorker s", b =>62 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorker", b => 63 63 { 64 64 b.Property<int>("Id") … … 111 111 112 112 b.Property<string>("Manufacturer") 113 .HasColumnType("text"); 114 115 b.Property<string>("Name") 113 .IsRequired() 114 .HasColumnType("text"); 115 116 b.Property<string>("Name") 117 .IsRequired() 116 118 .HasColumnType("text"); 117 119 … … 123 125 124 126 b.Property<string>("Strength") 127 .IsRequired() 125 128 .HasColumnType("text"); 126 129 127 130 b.Property<string>("WayOfIssuing") 131 .IsRequired() 128 132 .HasColumnType("text"); 129 133 … … 149 153 .HasColumnType("boolean"); 150 154 151 b.Property<int ?>("MedicineId")155 b.Property<int>("MedicineId") 152 156 .HasColumnType("integer"); 153 157 … … 190 194 191 195 b.Property<string>("Name") 196 .IsRequired() 192 197 .HasColumnType("text"); 193 198 … … 214 219 215 220 b.Property<string>("Address") 221 .IsRequired() 216 222 .HasColumnType("text"); 217 223 … … 223 229 224 230 b.Property<string>("Location") 225 .HasColumnType("text"); 226 227 b.Property<string>("Name") 231 .IsRequired() 232 .HasColumnType("text"); 233 234 b.Property<string>("Name") 235 .IsRequired() 228 236 .HasColumnType("text"); 229 237 … … 255 263 256 264 b.Property<string>("Email") 257 .HasColumnType("text"); 258 259 b.Property<string>("Name") 265 .IsRequired() 266 .HasColumnType("text"); 267 268 b.Property<string>("Name") 269 .IsRequired() 260 270 .HasColumnType("text"); 261 271 262 272 b.Property<string>("Password") 263 .HasColumnType("text"); 264 265 b.Property<int?>("PharmacyId") 266 .HasColumnType("integer"); 267 268 b.Property<int?>("PharmacyMedicinesId") 269 .HasColumnType("integer"); 270 271 b.HasKey("Id"); 273 .IsRequired() 274 .HasColumnType("text"); 275 276 b.HasKey("Id"); 277 278 b.ToTable("PharmacyHeads"); 279 }); 280 281 modelBuilder.Entity("FarmatikoData.Models.RequestPharmacyHead", b => 282 { 283 b.Property<int>("Id") 284 .ValueGeneratedOnAdd() 285 .HasColumnType("integer") 286 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 287 288 b.Property<DateTime>("CreatedOn") 289 .HasColumnType("timestamp without time zone"); 290 291 b.Property<DateTime?>("DeletedOn") 292 .HasColumnType("timestamp without time zone"); 293 294 b.Property<int>("HeadId") 295 .HasColumnType("integer"); 296 297 b.Property<int>("PharmacyId") 298 .HasColumnType("integer"); 299 300 b.HasKey("Id"); 301 302 b.HasIndex("HeadId"); 272 303 273 304 b.HasIndex("PharmacyId"); 274 305 275 b.HasIndex("PharmacyMedicinesId"); 276 277 b.ToTable("PharmacyHeads"); 278 }); 279 280 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorkers", b => 281 { 282 b.HasOne("FarmatikoData.Models.HealthFacilities", "Facility") 306 b.ToTable("PHRequests"); 307 }); 308 309 modelBuilder.Entity("FarmatikoData.Models.User", b => 310 { 311 b.Property<int>("Id") 312 .ValueGeneratedOnAdd() 313 .HasColumnType("integer") 314 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); 315 316 b.Property<DateTime>("CreatedOn") 317 .HasColumnType("timestamp without time zone"); 318 319 b.Property<DateTime?>("DeletedOn") 320 .HasColumnType("timestamp without time zone"); 321 322 b.Property<string>("Email") 323 .HasColumnType("text"); 324 325 b.Property<string>("Name") 326 .HasColumnType("text"); 327 328 b.Property<string>("Password") 329 .HasColumnType("text"); 330 331 b.Property<int>("UserRole") 332 .HasColumnType("integer"); 333 334 b.HasKey("Id"); 335 336 b.ToTable("Users"); 337 }); 338 339 modelBuilder.Entity("FarmatikoData.Models.HealthcareWorker", b => 340 { 341 b.HasOne("FarmatikoData.Models.HealthFacility", "Facility") 283 342 .WithMany() 284 343 .HasForeignKey("FacilityId") … … 291 350 b.HasOne("FarmatikoData.Models.Medicine", "Medicine") 292 351 .WithMany() 293 .HasForeignKey("MedicineId"); 352 .HasForeignKey("MedicineId") 353 .OnDelete(DeleteBehavior.Cascade) 354 .IsRequired(); 294 355 295 356 b.HasOne("FarmatikoData.Models.PharmacyHead", null) … … 305 366 }); 306 367 307 modelBuilder.Entity("FarmatikoData.Models.PharmacyHead", b => 308 { 368 modelBuilder.Entity("FarmatikoData.Models.RequestPharmacyHead", b => 369 { 370 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head") 371 .WithMany() 372 .HasForeignKey("HeadId") 373 .OnDelete(DeleteBehavior.Cascade) 374 .IsRequired(); 375 309 376 b.HasOne("FarmatikoData.Models.Pharmacy", "Pharmacy") 310 377 .WithMany() 311 .HasForeignKey("PharmacyId"); 312 313 b.HasOne("FarmatikoData.Models.MedicineList", "PharmacyMedicines") 314 .WithMany() 315 .HasForeignKey("PharmacyMedicinesId"); 378 .HasForeignKey("PharmacyId") 379 .OnDelete(DeleteBehavior.Cascade) 380 .IsRequired(); 316 381 }); 317 382 #pragma warning restore 612, 618 -
FarmatikoData/Models/PharmacyHead.cs
r1f4846d rd23bf72 16 16 [Required] 17 17 public string Password { get; set; } 18 public ICollection<MedicineList> MedicineLists { get; set; }19 public ICollection<Pharmacy> PharmaciesList { get; set; }18 public List<MedicineList> MedicineLists { get; set; } 19 public List<Pharmacy> PharmaciesList { get; set; } 20 20 21 21 }
Note:
See TracChangeset
for help on using the changeset viewer.