Changeset 1db5673 for FarmatikoData
- Timestamp:
- 11/14/20 12:27:30 (4 years ago)
- Branches:
- master
- Children:
- 68454c6
- Parents:
- ad60966
- Location:
- FarmatikoData
- Files:
-
- 1 added
- 1 deleted
- 12 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/Base/BaseEntity.cs
rad60966 r1db5673 3 3 using System.Text; 4 4 using System.ComponentModel.DataAnnotations; 5 using System.Text.Json.Serialization; 5 6 6 7 namespace FarmatikoData.Base … … 8 9 public class BaseEntity 9 10 { 10 public int Id { get; set; } 11 [JsonPropertyName("id")] 12 public int Id { get; set; } 11 13 public DateTime CreatedOn { get; set; } 12 14 public DateTime? DeletedOn { get; set; } -
FarmatikoData/FarmatikoData.csproj
rad60966 r1db5673 6 6 7 7 <ItemGroup> 8 <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6"> 8 <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.10" /> 9 <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.10" /> 10 <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.10"> 9 11 <PrivateAssets>all</PrivateAssets> 10 12 <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> 11 13 </PackageReference> 12 <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1. 6">14 <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.10"> 13 15 <PrivateAssets>all</PrivateAssets> 14 16 <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> -
FarmatikoData/FarmatikoDataContext.cs
rad60966 r1db5673 15 15 public virtual DbSet<Pandemic> Pandemics { get; set; } 16 16 public virtual DbSet<Medicine> Medicines { get; set; } 17 //public virtual DbSet<MedicineList> MedicineLists { get; set; }18 17 public virtual DbSet<RequestPharmacyHead> PHRequests { get; set; } 19 18 public virtual DbSet<User> Users { get; set; } 19 public virtual DbSet<PharmacyHeadMedicine> PharmacyHeadMedicines { get; set; } 20 21 protected override void OnModelCreating(ModelBuilder modelBuilder) 22 { 23 modelBuilder.Entity<PharmacyHead>() 24 .ToTable("PharmacyHeads"); 25 26 modelBuilder.Entity<Medicine>() 27 .ToTable("Medicines"); 28 29 modelBuilder.Entity<PharmacyHeadMedicine>() 30 .HasKey(phm => new { phm.PheadId, phm.MedicineId }); 31 modelBuilder.Entity<PharmacyHeadMedicine>() 32 .HasOne(ph => ph.Head) 33 .WithMany(m => m.PHMedicineList) 34 .HasForeignKey(k => k.PheadId); 35 36 modelBuilder.Entity<PharmacyHeadMedicine>() 37 .HasOne(m => m.Medicine) 38 .WithMany(ml => ml.MedicineList) 39 .HasForeignKey(k => k.MedicineId); 40 41 modelBuilder.Entity<PharmacyHead>() 42 .HasMany(p => p.PharmaciesList) 43 .WithOne(h => h.PHead) 44 .HasForeignKey(k => k.PheadId); 45 46 base.OnModelCreating(modelBuilder); 47 } 20 48 } 21 49 } -
FarmatikoData/FarmatikoRepo/PHRepo.cs
rad60966 r1db5673 31 31 Email = x.Email, 32 32 Password = x.Password, 33 MedicineList s = x.MedicineLists,33 MedicineList = x.MedicineList, 34 34 PharmaciesList = x.PharmaciesList 35 35 }).ToListAsync(); … … 39 39 public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead) 40 40 { 41 var EditedPHead = await _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefaultAsync(); 41 var Phead = await _context.PharmacyHeads.Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 42 var EditedPHead = await _context.PharmacyHeads.AsNoTracking<PharmacyHead>().Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 42 43 EditedPHead.Email = pharmacyHead.Email; 43 44 EditedPHead.Name = pharmacyHead.Name; 44 45 EditedPHead.Password = pharmacyHead.Password; 45 EditedPHead.MedicineLists = pharmacyHead.MedicineLists; 46 /*if (pharmacyHead.MedicineList.Count() == 0) 47 pharmacyHead.MedicineList = null;*/ 48 EditedPHead.MedicineList = pharmacyHead.MedicineList; 46 49 EditedPHead.PharmaciesList = pharmacyHead.PharmaciesList; 50 EditedPHead.PHMedicineList = pharmacyHead.PHMedicineList; 51 //_context.Entry<PharmacyHead>(Phead).State = EntityState.Detached; 52 Phead = EditedPHead; 47 53 await _context.SaveChangesAsync(); 48 54 } … … 72 78 } 73 79 80 74 81 public PharmacyHead GetPharmacyHeadByUserName(string userName) 75 82 { 76 return_context.PharmacyHeads83 var PHead = _context.PharmacyHeads 77 84 .Where(x => x.Email.Equals(userName)) 78 85 .FirstOrDefault(); 86 87 return PHead; 88 } 89 90 public List<PharmacyHeadMedicine> GetPharmacyHeadMedicines(string email) 91 { 92 /*var meds = _context.Medicines.ToList(); 93 var medicines = Medicines;*/ 94 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();*/ 99 100 101 return Medicines; 102 } 103 104 public IEnumerable<PharmacyHead> GetPharmacyHeads() 105 { 106 var heads = _context.PharmacyHeads.ToList(); 107 return heads; 108 } 109 110 public PharmacyHead GetPharmacyHead(string head) 111 { 112 var phead = _context.PharmacyHeads.Where(x => x.Email.Equals(head)).FirstOrDefault(); 113 return phead; 114 } 115 116 public List<Pharmacy> GetPharmacies() 117 { 118 var pharms = _context.Pharmacies.ToList(); 119 return pharms; 79 120 } 80 121 } -
FarmatikoData/FarmatikoRepo/Repository.cs
rad60966 r1db5673 41 41 } 42 42 43 public async Task<IEnumerable<Medicine>> GetMedicines() 44 { 45 var Medicines = await _context.Medicines.Take(3).ToListAsync(); 43 public async Task<IEnumerable<Medicine>> GetMedicinesAsync() 44 { 45 var Medicines = await _context.Medicines.Select(x => new Medicine 46 { 47 Name = x.Name, 48 Strength = x.Strength, 49 Form = x.Form, 50 WayOfIssuing = x.WayOfIssuing, 51 Manufacturer = x.Manufacturer, 52 Price = x.Price, 53 Packaging = x.Packaging 54 55 }).Take(3).ToListAsync(); 46 56 return Medicines; 47 57 } … … 205 215 public Task UpdateMedicine(Medicine medicine) 206 216 { 207 throw new System.NotImplementedException();217 throw new NotImplementedException(); 208 218 } 209 219 … … 227 237 return users; 228 238 } 239 240 public User GetRole(string userName) 241 { 242 var user = _context.Users.Where(x => x.Email.Equals(userName)).FirstOrDefault(); 243 return user; 244 } 245 246 public ICollection<Medicine> GetMedicines() 247 { 248 var Medicines = _context.Medicines.Select(x => new Medicine 249 { 250 Id = x.Id, 251 Name = x.Name, 252 Strength = x.Strength, 253 Form = x.Form, 254 WayOfIssuing = x.WayOfIssuing, 255 Manufacturer = x.Manufacturer, 256 Price = x.Price, 257 Packaging = x.Packaging, 258 MedicineList = x.MedicineList 259 260 }).ToList(); 261 return Medicines; 262 } 263 264 public ICollection<PharmacyHeadMedicine> GetPHMedicines(string email) 265 { 266 var head = _context.PharmacyHeads.Where(x => x.Email.Equals(email)).FirstOrDefault(); 267 var phmeds = _context.PharmacyHeadMedicines.Where(x => x.PheadId == head.Id).ToList(); 268 return phmeds; 269 } 229 270 } 230 271 } -
FarmatikoData/FarmatikoRepoInterfaces/IPHRepo.cs
rad60966 r1db5673 18 18 Task RemoveClaimingRequest(int id); 19 19 PharmacyHead GetPharmacyHeadByUserName(string userName); 20 List<PharmacyHeadMedicine> GetPharmacyHeadMedicines(string email); 21 IEnumerable<PharmacyHead> GetPharmacyHeads(); 22 PharmacyHead GetPharmacyHead(string head); 23 List<Pharmacy> GetPharmacies(); 20 24 } 21 25 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
rad60966 r1db5673 15 15 Task<HealthFacility> GetFacility(int Id); 16 16 Task<Medicine> GetMedicine(int Id); 17 Task<IEnumerable<Medicine>> GetMedicines(); 17 Task<IEnumerable<Medicine>> GetMedicinesAsync(); 18 ICollection<Medicine> GetMedicines(); 18 19 Task<Pandemic> GetPandemic(); 19 20 Task<IEnumerable<Pharmacy>> GetPharmacies(); … … 42 43 Task UpdateMedicine(Medicine medicine); 43 44 Task RemovePharmacyHead(int Id); 45 User GetRole(string userName); 46 ICollection<PharmacyHeadMedicine> GetPHMedicines(string email); 44 47 } 45 48 } -
FarmatikoData/Migrations/20201111183247_InitialMigration.Designer.cs
rad60966 r1db5673 11 11 { 12 12 [DbContext(typeof(FarmatikoDataContext))] 13 [Migration("202011 05063549_InitialMigration")]13 [Migration("20201111183247_InitialMigration")] 14 14 partial class InitialMigration 15 15 { … … 123 123 .HasColumnType("text"); 124 124 125 b.Property<int?>("PharmacyHeadId") 126 .HasColumnType("integer"); 127 125 128 b.Property<float>("Price") 126 129 .HasColumnType("real"); … … 136 139 b.HasKey("Id"); 137 140 141 b.HasIndex("PharmacyHeadId"); 142 138 143 b.ToTable("Medicines"); 139 });140 141 modelBuilder.Entity("FarmatikoData.Models.MedicineList", b =>142 {143 b.Property<int>("Id")144 .ValueGeneratedOnAdd()145 .HasColumnType("integer")146 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);147 148 b.Property<DateTime>("CreatedOn")149 .HasColumnType("timestamp without time zone");150 151 b.Property<DateTime?>("DeletedOn")152 .HasColumnType("timestamp without time zone");153 154 b.Property<bool>("HasMedicine")155 .HasColumnType("boolean");156 157 b.Property<int>("MedicineId")158 .HasColumnType("integer");159 160 b.Property<int?>("PharmacyHeadId")161 .HasColumnType("integer");162 163 b.HasKey("Id");164 165 b.HasIndex("MedicineId");166 167 b.HasIndex("PharmacyHeadId");168 169 b.ToTable("MedicineList");170 144 }); 171 145 … … 238 212 .HasColumnType("text"); 239 213 240 b.Property<int ?>("PharmacyHeadId")214 b.Property<int>("PheadId") 241 215 .HasColumnType("integer"); 242 216 … … 246 220 b.HasKey("Id"); 247 221 248 b.HasIndex("Ph armacyHeadId");222 b.HasIndex("PheadId"); 249 223 250 224 b.ToTable("Pharmacies"); … … 279 253 280 254 b.ToTable("PharmacyHeads"); 255 }); 256 257 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 258 { 259 b.Property<int>("PheadId") 260 .HasColumnType("integer"); 261 262 b.Property<int>("MedicineId") 263 .HasColumnType("integer"); 264 265 b.Property<DateTime>("CreatedOn") 266 .HasColumnType("timestamp without time zone"); 267 268 b.Property<DateTime?>("DeletedOn") 269 .HasColumnType("timestamp without time zone"); 270 271 b.Property<int>("Id") 272 .HasColumnType("integer"); 273 274 b.HasKey("PheadId", "MedicineId"); 275 276 b.HasIndex("MedicineId"); 277 278 b.ToTable("PharmacyHeadMedicines"); 281 279 }); 282 280 … … 348 346 }); 349 347 350 modelBuilder.Entity("FarmatikoData.Models.MedicineList", b => 348 modelBuilder.Entity("FarmatikoData.Models.Medicine", b => 349 { 350 b.HasOne("FarmatikoData.Models.PharmacyHead", null) 351 .WithMany("MedicineList") 352 .HasForeignKey("PharmacyHeadId"); 353 }); 354 355 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 356 { 357 b.HasOne("FarmatikoData.Models.PharmacyHead", "PHead") 358 .WithMany("PharmaciesList") 359 .HasForeignKey("PheadId") 360 .OnDelete(DeleteBehavior.Cascade) 361 .IsRequired(); 362 }); 363 364 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 351 365 { 352 366 b.HasOne("FarmatikoData.Models.Medicine", "Medicine") 353 .WithMany( )367 .WithMany("MedicineList") 354 368 .HasForeignKey("MedicineId") 355 369 .OnDelete(DeleteBehavior.Cascade) 356 370 .IsRequired(); 357 371 358 b.HasOne("FarmatikoData.Models.PharmacyHead", null) 359 .WithMany("MedicineLists") 360 .HasForeignKey("PharmacyHeadId"); 361 }); 362 363 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 364 { 365 b.HasOne("FarmatikoData.Models.PharmacyHead", null) 366 .WithMany("PharmaciesList") 367 .HasForeignKey("PharmacyHeadId"); 372 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head") 373 .WithMany("PHMedicineList") 374 .HasForeignKey("PheadId") 375 .OnDelete(DeleteBehavior.Cascade) 376 .IsRequired(); 368 377 }); 369 378 -
FarmatikoData/Migrations/20201111183247_InitialMigration.cs
rad60966 r1db5673 15 15 Id = table.Column<int>(nullable: false) 16 16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 17 CreatedOn = table.Column<DateTime>(nullable: false ),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), … … 30 30 31 31 migrationBuilder.CreateTable( 32 name: "Medicines",33 columns: table => new34 {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(53 32 name: "Pandemics", 54 33 columns: table => new … … 56 35 Id = table.Column<int>(nullable: false) 57 36 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 58 CreatedOn = table.Column<DateTime>(nullable: false ),37 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 59 38 DeletedOn = table.Column<DateTime>(nullable: true), 60 39 Name = table.Column<string>(nullable: false), … … 78 57 Id = table.Column<int>(nullable: false) 79 58 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 80 CreatedOn = table.Column<DateTime>(nullable: false ),59 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 81 60 DeletedOn = table.Column<DateTime>(nullable: true), 82 61 Email = table.Column<string>(nullable: false), … … 95 74 Id = table.Column<int>(nullable: false) 96 75 .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),76 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 77 DeletedOn = table.Column<DateTime>(nullable: true), 78 Name = table.Column<string>(nullable: false), 79 Email = table.Column<string>(nullable: false), 80 Password = table.Column<string>(nullable: false), 102 81 UserRole = table.Column<int>(nullable: false) 103 82 }, … … 113 92 Id = table.Column<int>(nullable: false) 114 93 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 115 CreatedOn = table.Column<DateTime>(nullable: false ),94 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 116 95 DeletedOn = table.Column<DateTime>(nullable: true), 117 96 Name = table.Column<string>(nullable: false), … … 132 111 133 112 migrationBuilder.CreateTable( 134 name: "MedicineList", 135 columns: table => new 136 { 137 Id = table.Column<int>(nullable: false) 138 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 139 CreatedOn = table.Column<DateTime>(nullable: false), 140 DeletedOn = table.Column<DateTime>(nullable: true), 141 MedicineId = table.Column<int>(nullable: false), 142 HasMedicine = table.Column<bool>(nullable: false), 113 name: "Medicines", 114 columns: table => new 115 { 116 Id = table.Column<int>(nullable: false) 117 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 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), 143 127 PharmacyHeadId = table.Column<int>(nullable: true) 144 128 }, 145 129 constraints: table => 146 130 { 147 table.PrimaryKey("PK_MedicineList", x => x.Id); 148 table.ForeignKey( 149 name: "FK_MedicineList_Medicines_MedicineId", 150 column: x => x.MedicineId, 151 principalTable: "Medicines", 152 principalColumn: "Id", 153 onDelete: ReferentialAction.Cascade); 154 table.ForeignKey( 155 name: "FK_MedicineList_PharmacyHeads_PharmacyHeadId", 131 table.PrimaryKey("PK_Medicines", x => x.Id); 132 table.ForeignKey( 133 name: "FK_Medicines_PharmacyHeads_PharmacyHeadId", 156 134 column: x => x.PharmacyHeadId, 157 135 principalTable: "PharmacyHeads", … … 172 150 Address = table.Column<string>(nullable: false), 173 151 WorkAllTime = table.Column<bool>(nullable: false), 174 Ph armacyHeadId = table.Column<int>(nullable: true)152 PheadId = table.Column<int>(nullable: false) 175 153 }, 176 154 constraints: table => … … 178 156 table.PrimaryKey("PK_Pharmacies", x => x.Id); 179 157 table.ForeignKey( 180 name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId", 181 column: x => x.PharmacyHeadId, 182 principalTable: "PharmacyHeads", 183 principalColumn: "Id", 184 onDelete: ReferentialAction.Restrict); 158 name: "FK_Pharmacies_PharmacyHeads_PheadId", 159 column: x => x.PheadId, 160 principalTable: "PharmacyHeads", 161 principalColumn: "Id", 162 onDelete: ReferentialAction.Cascade); 163 }); 164 165 migrationBuilder.CreateTable( 166 name: "PharmacyHeadMedicines", 167 columns: table => new 168 { 169 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 }); 178 table.ForeignKey( 179 name: "FK_PharmacyHeadMedicines_Medicines_MedicineId", 180 column: x => x.MedicineId, 181 principalTable: "Medicines", 182 principalColumn: "Id", 183 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); 185 190 }); 186 191 … … 191 196 Id = table.Column<int>(nullable: false) 192 197 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), 193 CreatedOn = table.Column<DateTime>(nullable: false ),198 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 194 199 DeletedOn = table.Column<DateTime>(nullable: true), 195 200 HeadId = table.Column<int>(nullable: false), … … 219 224 220 225 migrationBuilder.CreateIndex( 221 name: "IX_MedicineList_MedicineId", 222 table: "MedicineList", 226 name: "IX_Medicines_PharmacyHeadId", 227 table: "Medicines", 228 column: "PharmacyHeadId"); 229 230 migrationBuilder.CreateIndex( 231 name: "IX_Pharmacies_PheadId", 232 table: "Pharmacies", 233 column: "PheadId"); 234 235 migrationBuilder.CreateIndex( 236 name: "IX_PharmacyHeadMedicines_MedicineId", 237 table: "PharmacyHeadMedicines", 223 238 column: "MedicineId"); 224 225 migrationBuilder.CreateIndex(226 name: "IX_MedicineList_PharmacyHeadId",227 table: "MedicineList",228 column: "PharmacyHeadId");229 230 migrationBuilder.CreateIndex(231 name: "IX_Pharmacies_PharmacyHeadId",232 table: "Pharmacies",233 column: "PharmacyHeadId");234 239 235 240 migrationBuilder.CreateIndex( … … 250 255 251 256 migrationBuilder.DropTable( 252 name: "MedicineList");253 254 migrationBuilder.DropTable(255 257 name: "Pandemics"); 258 259 migrationBuilder.DropTable( 260 name: "PharmacyHeadMedicines"); 256 261 257 262 migrationBuilder.DropTable( -
FarmatikoData/Migrations/FarmatikoDataContextModelSnapshot.cs
rad60966 r1db5673 121 121 .HasColumnType("text"); 122 122 123 b.Property<int?>("PharmacyHeadId") 124 .HasColumnType("integer"); 125 123 126 b.Property<float>("Price") 124 127 .HasColumnType("real"); … … 134 137 b.HasKey("Id"); 135 138 139 b.HasIndex("PharmacyHeadId"); 140 136 141 b.ToTable("Medicines"); 137 });138 139 modelBuilder.Entity("FarmatikoData.Models.MedicineList", b =>140 {141 b.Property<int>("Id")142 .ValueGeneratedOnAdd()143 .HasColumnType("integer")144 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);145 146 b.Property<DateTime>("CreatedOn")147 .HasColumnType("timestamp without time zone");148 149 b.Property<DateTime?>("DeletedOn")150 .HasColumnType("timestamp without time zone");151 152 b.Property<bool>("HasMedicine")153 .HasColumnType("boolean");154 155 b.Property<int>("MedicineId")156 .HasColumnType("integer");157 158 b.Property<int?>("PharmacyHeadId")159 .HasColumnType("integer");160 161 b.HasKey("Id");162 163 b.HasIndex("MedicineId");164 165 b.HasIndex("PharmacyHeadId");166 167 b.ToTable("MedicineList");168 142 }); 169 143 … … 236 210 .HasColumnType("text"); 237 211 238 b.Property<int ?>("PharmacyHeadId")212 b.Property<int>("PheadId") 239 213 .HasColumnType("integer"); 240 214 … … 244 218 b.HasKey("Id"); 245 219 246 b.HasIndex("Ph armacyHeadId");220 b.HasIndex("PheadId"); 247 221 248 222 b.ToTable("Pharmacies"); … … 277 251 278 252 b.ToTable("PharmacyHeads"); 253 }); 254 255 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 256 { 257 b.Property<int>("PheadId") 258 .HasColumnType("integer"); 259 260 b.Property<int>("MedicineId") 261 .HasColumnType("integer"); 262 263 b.Property<DateTime>("CreatedOn") 264 .HasColumnType("timestamp without time zone"); 265 266 b.Property<DateTime?>("DeletedOn") 267 .HasColumnType("timestamp without time zone"); 268 269 b.Property<int>("Id") 270 .HasColumnType("integer"); 271 272 b.HasKey("PheadId", "MedicineId"); 273 274 b.HasIndex("MedicineId"); 275 276 b.ToTable("PharmacyHeadMedicines"); 279 277 }); 280 278 … … 346 344 }); 347 345 348 modelBuilder.Entity("FarmatikoData.Models.MedicineList", b => 346 modelBuilder.Entity("FarmatikoData.Models.Medicine", b => 347 { 348 b.HasOne("FarmatikoData.Models.PharmacyHead", null) 349 .WithMany("MedicineList") 350 .HasForeignKey("PharmacyHeadId"); 351 }); 352 353 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 354 { 355 b.HasOne("FarmatikoData.Models.PharmacyHead", "PHead") 356 .WithMany("PharmaciesList") 357 .HasForeignKey("PheadId") 358 .OnDelete(DeleteBehavior.Cascade) 359 .IsRequired(); 360 }); 361 362 modelBuilder.Entity("FarmatikoData.Models.PharmacyHeadMedicine", b => 349 363 { 350 364 b.HasOne("FarmatikoData.Models.Medicine", "Medicine") 351 .WithMany( )365 .WithMany("MedicineList") 352 366 .HasForeignKey("MedicineId") 353 367 .OnDelete(DeleteBehavior.Cascade) 354 368 .IsRequired(); 355 369 356 b.HasOne("FarmatikoData.Models.PharmacyHead", null) 357 .WithMany("MedicineLists") 358 .HasForeignKey("PharmacyHeadId"); 359 }); 360 361 modelBuilder.Entity("FarmatikoData.Models.Pharmacy", b => 362 { 363 b.HasOne("FarmatikoData.Models.PharmacyHead", null) 364 .WithMany("PharmaciesList") 365 .HasForeignKey("PharmacyHeadId"); 370 b.HasOne("FarmatikoData.Models.PharmacyHead", "Head") 371 .WithMany("PHMedicineList") 372 .HasForeignKey("PheadId") 373 .OnDelete(DeleteBehavior.Cascade) 374 .IsRequired(); 366 375 }); 367 376 -
FarmatikoData/Models/Medicine.cs
rad60966 r1db5673 1 1 using FarmatikoData.Base; 2 using System.Collections; 3 using System.Collections.Generic; 2 4 using System.ComponentModel.DataAnnotations; 5 using System.Diagnostics.CodeAnalysis; 6 using System.Text.Json.Serialization; 3 7 4 8 namespace FarmatikoData.Models … … 18 22 public float Price { get; set; } 19 23 public string Packaging { get; set; } 24 //[JsonPropertyName("PHMedicineList")] 25 public ICollection<PharmacyHeadMedicine> MedicineList { get; set; } 20 26 public Medicine(string Name, string Strength, string Form, string WayOfIssuing, string Manufacturer, float Price, string Packaging) 21 27 { … … 28 34 this.Packaging = Packaging; 29 35 } 30 31 36 } 32 37 } -
FarmatikoData/Models/Pharmacy.cs
rad60966 r1db5673 26 26 this.WorkAllTime = WorkAllTime; 27 27 } 28 public int PheadId { get; set; } 29 public PharmacyHead PHead { get; set; } 28 30 } 29 31 } -
FarmatikoData/Models/PharmacyHead.cs
rad60966 r1db5673 1 1 using System.Collections.Generic; 2 2 using System.ComponentModel.DataAnnotations; 3 using System.Text.Json.Serialization; 3 4 using FarmatikoData.Base; 5 using Newtonsoft.Json; 4 6 5 7 namespace FarmatikoData.Models … … 11 13 } 12 14 [Required] 15 [JsonProperty("Email")] 13 16 public string Email { get; set; } 14 17 [Required] 18 [JsonProperty("Name")] 15 19 public string Name { get; set; } 16 20 [Required] 21 [JsonProperty("Passwd")] 17 22 public string Password { get; set; } 18 public List<MedicineList> MedicineLists { get; set; } 19 public List<Pharmacy> PharmaciesList { get; set; } 23 [JsonProperty("PharmacyMedicines")] 24 public List<Medicine> MedicineList { get; set; } 25 [Required] 26 [JsonProperty("Pharmacy")] 27 public ICollection<Pharmacy> PharmaciesList { get; set; } 28 //[JsonProperty("PHMedicineList")] 29 public ICollection<PharmacyHeadMedicine> PHMedicineList { get; set; } 20 30 21 31 } -
FarmatikoData/Models/RequestPharmacyHead.cs
rad60966 r1db5673 4 4 using System.ComponentModel.DataAnnotations; 5 5 using System.Text; 6 using System.Text.Json.Serialization; 6 7 7 8 namespace FarmatikoData.Models … … 13 14 } 14 15 [Required] 16 [JsonPropertyName("PharmacyHead")] 15 17 public PharmacyHead Head { get; set; } 16 18 [Required] 19 [JsonPropertyName("Pharmacy")] 17 20 public Pharmacy Pharmacy { get; set; } 18 21
Note:
See TracChangeset
for help on using the changeset viewer.