Changeset db484c9 for FarmatikoData
- Timestamp:
- 01/26/21 10:33:09 (4 years ago)
- Branches:
- master
- Children:
- 7d80751
- Parents:
- 8e74e2f
- Location:
- FarmatikoData
- Files:
-
- 1 added
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoDataContext.cs
r8e74e2f rdb484c9 9 9 10 10 11 public virtualDbSet<HealthFacility> HealthFacilities { get; set; }12 public virtualDbSet<HealthcareWorker> HealthcareWorkers { get; set; }13 public virtualDbSet<Pharmacy> Pharmacies { get; set; }14 public virtualDbSet<PharmacyHead> PharmacyHeads { get; set; }15 public virtualDbSet<Pandemic> Pandemics { get; set; }16 public virtualDbSet<Medicine> Medicines { get; set; }17 public virtualDbSet<RequestPharmacyHead> PHRequests { get; set; }18 public virtualDbSet<User> Users { get; set; }19 public virtualDbSet<PharmacyHeadMedicine> PharmacyHeadMedicines { get; set; }11 public DbSet<HealthFacility> HealthFacilities { get; set; } 12 public DbSet<HealthcareWorker> HealthcareWorkers { get; set; } 13 public DbSet<Pharmacy> Pharmacies { get; set; } 14 public DbSet<PharmacyHead> PharmacyHeads { get; set; } 15 public DbSet<Pandemic> Pandemics { get; set; } 16 public DbSet<Medicine> Medicines { get; set; } 17 public DbSet<RequestPharmacyHead> PHRequests { get; set; } 18 public DbSet<User> Users { get; set; } 19 public DbSet<PharmacyHeadMedicine> PharmacyHeadMedicines { get; set; } 20 20 21 21 protected override void OnModelCreating(ModelBuilder modelBuilder) … … 31 31 modelBuilder.Entity<Pharmacy>() 32 32 .ToTable("Pharmacies"); 33 34 modelBuilder.Entity<PharmacyHeadMedicine>() 35 .ToTable("PharmacyHeadMedicines"); 36 37 modelBuilder.Entity<RequestPharmacyHead>() 38 .ToTable("PHRequests"); 33 39 34 40 modelBuilder.Entity<Medicine>() … … 52 58 .HasIdentityOptions(startValue: 1); 53 59 54 modelBuilder.Entity<User>()60 /*modelBuilder.Entity<User>() 55 61 .Property(x => x.Id) 56 62 .HasIdentityOptions(startValue: 1); … … 58 64 modelBuilder.Entity<PharmacyHeadMedicine>() 59 65 .HasKey(phm => new { phm.PheadId, phm.MedicineId }); 60 modelBuilder.Entity<PharmacyHeadMedicine>()61 .HasOne(ph => ph.Head)62 .WithMany(m => m.PHMedicineList)63 .HasForeignKey(k => k.PheadId);64 65 modelBuilder.Entity<PharmacyHeadMedicine>()66 .HasOne(m => m.Medicine)67 .WithMany(ml => ml.MedicineList)68 .HasForeignKey(k => k.MedicineId);69 66 70 67 modelBuilder.Entity<PharmacyHead>() 71 .HasMany (p => p.PharmaciesList)72 .WithOne( h => h.PHead)73 .HasForeignKey( k => k.PheadId);68 .HasMany<Pharmacy>(p => p.Pharmacy) 69 .WithOne(p => p.PharmacyHead) 70 .HasForeignKey(); 74 71 75 76 72 modelBuilder.Entity<Pharmacy>() 73 .HasOne<PharmacyHead>(p => p.PharmacyHead) 74 .WithMany(p => p.Pharmacy); 75 */ 76 77 77 base.OnModelCreating(modelBuilder); 78 78 } -
FarmatikoData/FarmatikoRepo/AdminRepo.cs
r8e74e2f rdb484c9 27 27 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads() 28 28 { 29 var PHeads = await _context.PharmacyHeads.OrderBy(x => x.Name).ToListAsync(); 29 var PHeads = await _context.PharmacyHeads 30 .Include(x => x.Medicines) 31 .Include(x => x.Pharmacies) 32 .OrderBy(x => x.Name) 33 .ToListAsync(); 30 34 return PHeads; 31 35 } 32 36 //POST 33 public void RemoveClaimRequest(int Id)37 public async void RemoveClaimRequest(int Id) 34 38 { 35 39 var req = _context.PHRequests.Where(x => x.Id == Id).FirstOrDefault(); 36 40 _context.PHRequests.Remove(req); 37 _context.SaveChanges();41 await _context.SaveChangesAsync(); 38 42 } 39 43 } -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r8e74e2f rdb484c9 24 24 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo() 25 25 { 26 var PHeadInfo = await _context.PharmacyHeads.Take(10).Where(x => x.DeletedOn == null) 26 var PHeadInfo = await _context.PharmacyHeads.Take(10) 27 .Where(x => x.DeletedOn == null) 27 28 .Select(x => new PharmacyHead 28 29 { … … 31 32 Email = x.Email, 32 33 Password = x.Password, 33 MedicineList = x.MedicineList, 34 PharmaciesList = x.PharmaciesList 34 Pharmacies = x.Pharmacies, 35 Medicines = x.Medicines 36 35 37 }).ToListAsync(); 36 38 return PHeadInfo; … … 41 43 var Phead = await _context.PharmacyHeads.Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 42 44 var EditedPHead = await _context.PharmacyHeads.AsNoTracking<PharmacyHead>().Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 43 EditedPHead.Email = pharmacyHead.Email; 44 EditedPHead.Name = pharmacyHead.Name; 45 EditedPHead.Password = pharmacyHead.Password; 46 /*if (pharmacyHead.MedicineList.Count() == 0) 47 pharmacyHead.MedicineList = null;*/ 48 EditedPHead.MedicineList = pharmacyHead.MedicineList; 49 EditedPHead.PharmaciesList = pharmacyHead.PharmaciesList; 50 EditedPHead.PHMedicineList = pharmacyHead.PHMedicineList; 51 //_context.Entry<PharmacyHead>(Phead).State = EntityState.Detached; 52 //Phead = EditedPHead; 45 46 if (!EditedPHead.Email.Equals(pharmacyHead.Email)) 47 EditedPHead.Email = pharmacyHead.Email; 48 49 if (!EditedPHead.Name.Equals(pharmacyHead.Name)) 50 EditedPHead.Name = pharmacyHead.Name; 51 52 if (!EditedPHead.Password.Equals(pharmacyHead.Password)) 53 EditedPHead.Password = pharmacyHead.Password; 54 55 if (!EditedPHead.Pharmacies.Equals(pharmacyHead.Pharmacies)) 56 EditedPHead.Pharmacies = pharmacyHead.Pharmacies; 57 58 if (!EditedPHead.Medicines.Equals(pharmacyHead.Medicines)) 59 EditedPHead.Medicines = pharmacyHead.Medicines; 60 53 61 await _context.SaveChangesAsync(); 54 62 } … … 81 89 public PharmacyHead GetPharmacyHeadByUserName(string userName) 82 90 { 91 92 83 93 var PHead = _context.PharmacyHeads 84 94 .Where(x => x.Email.Equals(userName)) 85 .FirstOrDefault(); 95 .Select(x => new PharmacyHead 96 { 97 Email = x.Email, 98 Name = x.Name, 99 Password = x.Password, 100 Medicines = x.Medicines, 101 Pharmacies = x.Pharmacies 102 }).FirstOrDefault(); 103 104 86 105 87 106 return PHead; … … 90 109 public List<PharmacyHeadMedicine> GetPharmacyHeadMedicines(string email) 91 110 { 92 /*var meds = _context.Medicines.ToList();93 var medicines = Medicines;*/94 111 var Phead = _context.PharmacyHeads.Where(x => x.Email.Equals(email)).FirstOrDefault(); 95 var Medicines = _context.PharmacyHeadMedicines.Where(x => x.PheadId == Phead.Id).ToList(); 96 /*.Select(x => x.Head.MedicineList) 97 .SelectMany(mList => mList) 98 .ToList();*/ 112 var Medicines = _context.PharmacyHeadMedicines.Select(x => new PharmacyHeadMedicine 113 { 114 PheadId = x.PheadId, 115 Head = x.Head, 116 MedicineId = x.MedicineId, 117 Medicine = x.Medicine 118 }).ToList(); 119 if (Medicines == null || Medicines == default) 120 Medicines = null; 121 var meds = Medicines.Where(x => x.PheadId == Phead.Id).ToList(); 99 122 100 101 return Medicines; 123 return meds; 102 124 } 103 125 -
FarmatikoData/FarmatikoRepo/Repository.cs
r8e74e2f rdb484c9 86 86 var SearchQuery = await _context.HealthFacilities 87 87 .Where(x => x.Name.Contains(query)) 88 .OrderBy(x => x.Name).T ake(3).ToListAsync();88 .OrderBy(x => x.Name).ToListAsync(); 89 89 90 90 return SearchQuery; … … 95 95 var SearchQuery = await _context.Medicines 96 96 .Where(x => x.Name.Contains(query)) 97 .OrderBy(x => x.Name).T ake(5).ToListAsync();97 .OrderBy(x => x.Name).ToListAsync(); 98 98 99 99 return SearchQuery; … … 104 104 var SearchQuery = await _context.Pharmacies.Take(5) 105 105 .Where(x => x.Name.Contains(query)) 106 .OrderBy(x => x.Name).T ake(5).ToListAsync();106 .OrderBy(x => x.Name).ToListAsync(); 107 107 108 108 return SearchQuery; … … 113 113 var SearchQuery = await _context.HealthcareWorkers.Take(5) 114 114 .Where(x => x.Name.Contains(query)) 115 .OrderBy(x => x.Name).T ake(5).ToListAsync();115 .OrderBy(x => x.Name).ToListAsync(); 116 116 117 117 return SearchQuery; … … 170 170 Facility.Phone = healthFacility.Phone; 171 171 Facility.Type = healthFacility.Type; 172 _context.SaveChanges();172 await _context.SaveChangesAsync(); 173 173 } 174 174 175 175 public async Task RemoveMedicine(Medicine medicine) 176 176 { 177 await Task.Run(() => _context.Medicines.Remove(medicine));178 _context.SaveChanges();177 _context.Medicines.Remove(medicine); 178 await _context.SaveChangesAsync(); 179 179 } 180 180 … … 190 190 Pandemic.TotalGlobal = pandemic.TotalGlobal; 191 191 Pandemic.TotalMK = pandemic.TotalMK; 192 _context.SaveChanges();192 await _context.SaveChangesAsync(); 193 193 } 194 194 195 195 public async Task RemovePharmacy(Pharmacy pharmacy) 196 196 { 197 await Task.Run(() => _context.Pharmacies.Remove(pharmacy));198 _context.SaveChanges();197 _context.Pharmacies.Remove(pharmacy); 198 await _context.SaveChangesAsync(); 199 199 } 200 200 //not impl … … 211 211 Pharmacy.WorkAllTime = pharmacy.WorkAllTime; 212 212 Pharmacy.Address = pharmacy.Address; 213 _context.SaveChanges();214 } 215 // ke vidime213 await _context.SaveChangesAsync(); 214 } 215 //not implemented, not needed 216 216 public Task UpdateMedicine(Medicine medicine) 217 217 { … … 223 223 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 224 224 PHead.DeletedOn = DateTime.UtcNow; 225 _context.SaveChanges();225 await _context.SaveChangesAsync(); 226 226 } 227 227 … … 236 236 UserRole = x.UserRole 237 237 }); 238 238 239 return users; 239 240 } … … 257 258 Price = x.Price, 258 259 Packaging = x.Packaging, 259 Medicine List = x.MedicineList260 Medicines = x.Medicines 260 261 261 262 }).ToList(); … … 266 267 { 267 268 var head = _context.PharmacyHeads.Where(x => x.Email.Equals(email)).FirstOrDefault(); 268 var phmeds = _context.PharmacyHeadMedicines.Where(x => x.PheadId == head.Id). ToList();269 var phmeds = _context.PharmacyHeadMedicines.Where(x => x.PheadId == head.Id).Include(x => x.Medicine).ToList(); 269 270 return phmeds; 270 271 } -
FarmatikoData/Migrations/20210124191844_InitialMigration.Designer.cs
r8e74e2f rdb484c9 11 11 { 12 12 [DbContext(typeof(FarmatikoDataContext))] 13 [Migration("202 01115222819_InitialMigration")]13 [Migration("20210124191844_InitialMigration")] 14 14 partial class InitialMigration 15 15 { … … 124 124 .HasColumnType("text"); 125 125 126 b.Property<int?>("PharmacyHeadId")127 .HasColumnType("integer");128 129 126 b.Property<float>("Price") 130 127 .HasColumnType("real"); … … 140 137 b.HasKey("Id"); 141 138 142 b.HasIndex("PharmacyHeadId");143 144 139 b.ToTable("Medicines"); 145 140 }); … … 214 209 .HasColumnType("text"); 215 210 211 b.Property<int?>("PharmacyHeadId") 212 .HasColumnType("integer"); 213 216 214 b.Property<int>("PheadId") 217 215 .HasColumnType("integer"); … … 222 220 b.HasKey("Id"); 223 221 224 b.HasIndex("Ph eadId");222 b.HasIndex("PharmacyHeadId"); 225 223 226 224 b.ToTable("Pharmacies"); … … 253 251 .HasColumnType("text"); 254 252 255 b.HasKey("Id"); 253 b.Property<int?>("UserId") 254 .HasColumnType("integer"); 255 256 b.HasKey("Id"); 257 258 b.HasIndex("UserId"); 256 259 257 260 b.ToTable("PharmacyHeads"); … … 260 263 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 261 264 { 265 b.Property<int>("Id") 266 .ValueGeneratedOnAdd() 267 .HasColumnType("integer") 268 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 269 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 270 271 b.Property<DateTime>("CreatedOn") 272 .HasColumnType("timestamp without time zone"); 273 274 b.Property<DateTime?>("DeletedOn") 275 .HasColumnType("timestamp without time zone"); 276 277 b.Property<int?>("HeadId") 278 .HasColumnType("integer"); 279 280 b.Property<int>("MedicineId") 281 .HasColumnType("integer"); 282 262 283 b.Property<int>("PheadId") 263 284 .HasColumnType("integer"); 264 285 265 b.Property<int>("MedicineId") 266 .HasColumnType("integer"); 267 268 b.Property<DateTime>("CreatedOn") 269 .HasColumnType("timestamp without time zone"); 270 271 b.Property<DateTime?>("DeletedOn") 272 .HasColumnType("timestamp without time zone"); 273 274 b.Property<int>("Id") 275 .HasColumnType("integer") 276 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'"); 277 278 b.HasKey("PheadId", "MedicineId"); 286 b.HasKey("Id"); 287 288 b.HasIndex("HeadId"); 279 289 280 290 b.HasIndex("MedicineId"); … … 317 327 .ValueGeneratedOnAdd() 318 328 .HasColumnType("integer") 319 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")320 329 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 321 330 … … 355 364 }); 356 365 357 modelBuilder.Entity("FarmatikoData.Models. Medicine", b =>358 { 359 b.HasOne("FarmatikoData.Models.PharmacyHead", null)360 .WithMany(" MedicineList")366 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 367 { 368 b.HasOne("FarmatikoData.Models.PharmacyHead", "PharmacyHead") 369 .WithMany("Pharmacies") 361 370 .HasForeignKey("PharmacyHeadId"); 362 371 }); 363 372 364 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 365 { 366 b.HasOne("FarmatikoData.Models.PharmacyHead", "PHead") 367 .WithMany("PharmaciesList") 368 .HasForeignKey("PheadId") 369 .OnDelete(DeleteBehavior.Cascade) 370 .IsRequired(); 373 modelBuilder.Entity("FarmatikoData.Models.PharmacyHead", b => 374 { 375 b.HasOne("FarmatikoData.Models.User", "User") 376 .WithMany() 377 .HasForeignKey("UserId"); 371 378 }); 372 379 373 380 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 374 381 { 382 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head") 383 .WithMany("Medicines") 384 .HasForeignKey("HeadId"); 385 375 386 b.HasOne("FarmatikoData.Models.Medicine", "Medicine") 376 .WithMany("Medicine List")387 .WithMany("Medicines") 377 388 .HasForeignKey("MedicineId") 378 .OnDelete(DeleteBehavior.Cascade)379 .IsRequired();380 381 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head")382 .WithMany("PHMedicineList")383 .HasForeignKey("PheadId")384 389 .OnDelete(DeleteBehavior.Cascade) 385 390 .IsRequired(); -
FarmatikoData/Migrations/20210124191844_InitialMigration.cs
r8e74e2f rdb484c9 15 15 Id = table.Column<int>(nullable: false) 16 16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 17 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),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), … … 27 27 { 28 28 table.PrimaryKey("PK_HealthFacilities", x => x.Id); 29 }); 30 31 migrationBuilder.CreateTable( 32 name: "Medicines", 33 columns: table => new 34 { 35 Id = table.Column<int>(nullable: false) 36 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 37 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 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); 29 50 }); 30 51 … … 52 73 53 74 migrationBuilder.CreateTable( 54 name: "PharmacyHeads",55 columns: table => new56 {57 Id = table.Column<int>(nullable: false)58 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),59 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),60 DeletedOn = table.Column<DateTime>(nullable: true),61 Email = table.Column<string>(nullable: false),62 Name = table.Column<string>(nullable: false),63 Password = table.Column<string>(nullable: false)64 },65 constraints: table =>66 {67 table.PrimaryKey("PK_PharmacyHeads", x => x.Id);68 });69 70 migrationBuilder.CreateTable(71 75 name: "Users", 72 76 columns: table => new … … 111 115 112 116 migrationBuilder.CreateTable( 113 name: "Medicines", 114 columns: table => new 115 { 116 Id = table.Column<int>(nullable: false) 117 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 118 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 119 DeletedOn = table.Column<DateTime>(nullable: true), 120 Name = table.Column<string>(nullable: false), 121 Strength = table.Column<string>(nullable: false), 122 Form = table.Column<string>(nullable: true), 123 WayOfIssuing = table.Column<string>(nullable: false), 124 Manufacturer = table.Column<string>(nullable: false), 125 Price = table.Column<float>(nullable: false), 126 Packaging = table.Column<string>(nullable: true), 127 PharmacyHeadId = table.Column<int>(nullable: true) 128 }, 129 constraints: table => 130 { 131 table.PrimaryKey("PK_Medicines", x => x.Id); 132 table.ForeignKey( 133 name: "FK_Medicines_PharmacyHeads_PharmacyHeadId", 134 column: x => x.PharmacyHeadId, 135 principalTable: "PharmacyHeads", 117 name: "PharmacyHeads", 118 columns: table => new 119 { 120 Id = table.Column<int>(nullable: false) 121 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 122 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 123 DeletedOn = table.Column<DateTime>(nullable: true), 124 Email = table.Column<string>(nullable: false), 125 Name = table.Column<string>(nullable: false), 126 Password = table.Column<string>(nullable: false), 127 UserId = table.Column<int>(nullable: true) 128 }, 129 constraints: table => 130 { 131 table.PrimaryKey("PK_PharmacyHeads", x => x.Id); 132 table.ForeignKey( 133 name: "FK_PharmacyHeads_Users_UserId", 134 column: x => x.UserId, 135 principalTable: "Users", 136 136 principalColumn: "Id", 137 137 onDelete: ReferentialAction.Restrict); … … 150 150 Address = table.Column<string>(nullable: false), 151 151 WorkAllTime = table.Column<bool>(nullable: false), 152 PheadId = table.Column<int>(nullable: false) 152 PheadId = table.Column<int>(nullable: false), 153 PharmacyHeadId = table.Column<int>(nullable: true) 153 154 }, 154 155 constraints: table => … … 156 157 table.PrimaryKey("PK_Pharmacies", x => x.Id); 157 158 table.ForeignKey( 158 name: "FK_Pharmacies_PharmacyHeads_Ph eadId",159 column: x => x.Ph eadId,159 name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId", 160 column: x => x.PharmacyHeadId, 160 161 principalTable: "PharmacyHeads", 161 162 principalColumn: "Id", 162 onDelete: ReferentialAction. Cascade);163 onDelete: ReferentialAction.Restrict); 163 164 }); 164 165 … … 167 168 columns: table => new 168 169 { 170 Id = table.Column<int>(nullable: false) 171 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 172 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 173 DeletedOn = table.Column<DateTime>(nullable: true), 169 174 PheadId = table.Column<int>(nullable: false), 170 MedicineId = table.Column<int>(nullable: false), 171 Id = table.Column<int>(nullable: false), 172 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 173 DeletedOn = table.Column<DateTime>(nullable: true) 174 }, 175 constraints: table => 176 { 177 table.PrimaryKey("PK_PharmacyHeadMedicines", x => new { x.PheadId, x.MedicineId }); 175 HeadId = table.Column<int>(nullable: true), 176 MedicineId = table.Column<int>(nullable: false) 177 }, 178 constraints: table => 179 { 180 table.PrimaryKey("PK_PharmacyHeadMedicines", x => x.Id); 181 table.ForeignKey( 182 name: "FK_PharmacyHeadMedicines_PharmacyHeads_HeadId", 183 column: x => x.HeadId, 184 principalTable: "PharmacyHeads", 185 principalColumn: "Id", 186 onDelete: ReferentialAction.Restrict); 178 187 table.ForeignKey( 179 188 name: "FK_PharmacyHeadMedicines_Medicines_MedicineId", … … 182 191 principalColumn: "Id", 183 192 onDelete: ReferentialAction.Cascade); 184 table.ForeignKey(185 name: "FK_PharmacyHeadMedicines_PharmacyHeads_PheadId",186 column: x => x.PheadId,187 principalTable: "PharmacyHeads",188 principalColumn: "Id",189 onDelete: ReferentialAction.Cascade);190 193 }); 191 194 … … 224 227 225 228 migrationBuilder.CreateIndex( 226 name: "IX_ Medicines_PharmacyHeadId",227 table: " Medicines",229 name: "IX_Pharmacies_PharmacyHeadId", 230 table: "Pharmacies", 228 231 column: "PharmacyHeadId"); 229 232 230 233 migrationBuilder.CreateIndex( 231 name: "IX_Pharmac ies_PheadId",232 table: "Pharmac ies",233 column: " PheadId");234 name: "IX_PharmacyHeadMedicines_HeadId", 235 table: "PharmacyHeadMedicines", 236 column: "HeadId"); 234 237 235 238 migrationBuilder.CreateIndex( … … 237 240 table: "PharmacyHeadMedicines", 238 241 column: "MedicineId"); 242 243 migrationBuilder.CreateIndex( 244 name: "IX_PharmacyHeads_UserId", 245 table: "PharmacyHeads", 246 column: "UserId"); 239 247 240 248 migrationBuilder.CreateIndex( … … 264 272 265 273 migrationBuilder.DropTable( 274 name: "HealthFacilities"); 275 276 migrationBuilder.DropTable( 277 name: "Medicines"); 278 279 migrationBuilder.DropTable( 280 name: "Pharmacies"); 281 282 migrationBuilder.DropTable( 283 name: "PharmacyHeads"); 284 285 migrationBuilder.DropTable( 266 286 name: "Users"); 267 268 migrationBuilder.DropTable(269 name: "HealthFacilities");270 271 migrationBuilder.DropTable(272 name: "Medicines");273 274 migrationBuilder.DropTable(275 name: "Pharmacies");276 277 migrationBuilder.DropTable(278 name: "PharmacyHeads");279 287 } 280 288 } -
FarmatikoData/Migrations/FarmatikoDataContextModelSnapshot.cs
r8e74e2f rdb484c9 122 122 .HasColumnType("text"); 123 123 124 b.Property<int?>("PharmacyHeadId")125 .HasColumnType("integer");126 127 124 b.Property<float>("Price") 128 125 .HasColumnType("real"); … … 138 135 b.HasKey("Id"); 139 136 140 b.HasIndex("PharmacyHeadId");141 142 137 b.ToTable("Medicines"); 143 138 }); … … 212 207 .HasColumnType("text"); 213 208 209 b.Property<int?>("PharmacyHeadId") 210 .HasColumnType("integer"); 211 214 212 b.Property<int>("PheadId") 215 213 .HasColumnType("integer"); … … 220 218 b.HasKey("Id"); 221 219 222 b.HasIndex("Ph eadId");220 b.HasIndex("PharmacyHeadId"); 223 221 224 222 b.ToTable("Pharmacies"); … … 251 249 .HasColumnType("text"); 252 250 253 b.HasKey("Id"); 251 b.Property<int?>("UserId") 252 .HasColumnType("integer"); 253 254 b.HasKey("Id"); 255 256 b.HasIndex("UserId"); 254 257 255 258 b.ToTable("PharmacyHeads"); … … 258 261 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 259 262 { 263 b.Property<int>("Id") 264 .ValueGeneratedOnAdd() 265 .HasColumnType("integer") 266 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'") 267 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 268 269 b.Property<DateTime>("CreatedOn") 270 .HasColumnType("timestamp without time zone"); 271 272 b.Property<DateTime?>("DeletedOn") 273 .HasColumnType("timestamp without time zone"); 274 275 b.Property<int?>("HeadId") 276 .HasColumnType("integer"); 277 278 b.Property<int>("MedicineId") 279 .HasColumnType("integer"); 280 260 281 b.Property<int>("PheadId") 261 282 .HasColumnType("integer"); 262 283 263 b.Property<int>("MedicineId") 264 .HasColumnType("integer"); 265 266 b.Property<DateTime>("CreatedOn") 267 .HasColumnType("timestamp without time zone"); 268 269 b.Property<DateTime?>("DeletedOn") 270 .HasColumnType("timestamp without time zone"); 271 272 b.Property<int>("Id") 273 .HasColumnType("integer") 274 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'"); 275 276 b.HasKey("PheadId", "MedicineId"); 284 b.HasKey("Id"); 285 286 b.HasIndex("HeadId"); 277 287 278 288 b.HasIndex("MedicineId"); … … 315 325 .ValueGeneratedOnAdd() 316 326 .HasColumnType("integer") 317 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")318 327 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 319 328 … … 353 362 }); 354 363 355 modelBuilder.Entity("FarmatikoData.Models. Medicine", b =>356 { 357 b.HasOne("FarmatikoData.Models.PharmacyHead", null)358 .WithMany(" MedicineList")364 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 365 { 366 b.HasOne("FarmatikoData.Models.PharmacyHead", "PharmacyHead") 367 .WithMany("Pharmacies") 359 368 .HasForeignKey("PharmacyHeadId"); 360 369 }); 361 370 362 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 363 { 364 b.HasOne("FarmatikoData.Models.PharmacyHead", "PHead") 365 .WithMany("PharmaciesList") 366 .HasForeignKey("PheadId") 367 .OnDelete(DeleteBehavior.Cascade) 368 .IsRequired(); 371 modelBuilder.Entity("FarmatikoData.Models.PharmacyHead", b => 372 { 373 b.HasOne("FarmatikoData.Models.User", "User") 374 .WithMany() 375 .HasForeignKey("UserId"); 369 376 }); 370 377 371 378 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 372 379 { 380 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head") 381 .WithMany("Medicines") 382 .HasForeignKey("HeadId"); 383 373 384 b.HasOne("FarmatikoData.Models.Medicine", "Medicine") 374 .WithMany("Medicine List")385 .WithMany("Medicines") 375 386 .HasForeignKey("MedicineId") 376 .OnDelete(DeleteBehavior.Cascade)377 .IsRequired();378 379 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head")380 .WithMany("PHMedicineList")381 .HasForeignKey("PheadId")382 387 .OnDelete(DeleteBehavior.Cascade) 383 388 .IsRequired(); -
FarmatikoData/Models/Medicine.cs
r8e74e2f rdb484c9 23 23 public string Packaging { get; set; } 24 24 //[JsonPropertyName("PHMedicineList")] 25 public ICollection<PharmacyHeadMedicine> Medicine List{ get; set; }25 public ICollection<PharmacyHeadMedicine> Medicines { get; set; } 26 26 public Medicine(string Name, string Strength, string Form, string WayOfIssuing, string Manufacturer, float Price, string Packaging) 27 27 { -
FarmatikoData/Models/Pharmacy.cs
r8e74e2f rdb484c9 27 27 } 28 28 public int PheadId { get; set; } 29 public PharmacyHead P Head { get; internalset; }29 public PharmacyHead PharmacyHead { get; set; } 30 30 } 31 31 } -
FarmatikoData/Models/PharmacyHead.cs
r8e74e2f rdb484c9 21 21 [JsonProperty("Passwd")] 22 22 public string Password { get; set; } 23 [JsonProperty("PharmacyList")] 24 public virtual List<Pharmacy> Pharmacies { get; set; } 25 public virtual List<PharmacyHeadMedicine> Medicines { get; set; } 26 27 public User User { get; set; } 23 28 24 [JsonProperty("PharmacyMedicines")]25 public List<Medicine> MedicineList { get; set; }26 [JsonProperty("Pharmacy")]27 public ICollection<Pharmacy> PharmaciesList { get; set; }28 //[JsonProperty("PHMedicineList")]29 public ICollection<PharmacyHeadMedicine> PHMedicineList { get; set; }30 29 31 30 }
Note:
See TracChangeset
for help on using the changeset viewer.