Changeset 0a694bb for FarmatikoData
- Timestamp:
- 02/07/21 16:25:56 (4 years ago)
- Branches:
- master
- Children:
- e0cdea2
- Parents:
- ac51326
- Location:
- FarmatikoData
- Files:
-
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/DTOs/PharmacyDTO.cs
rac51326 r0a694bb 11 11 [JsonProperty("name")] 12 12 public string Name { get; set; } 13 [JsonProperty(" Location")]13 [JsonProperty("location")] 14 14 public string Location { get; set; } 15 15 [JsonProperty("address")] 16 16 public string Address { get; set; } 17 [JsonProperty("work alltime")]17 [JsonProperty("workAllTime")] 18 18 public bool WorkAllTime { get; set; } 19 19 [JsonProperty("headName")] -
FarmatikoData/FarmatikoDataContext.cs
rac51326 r0a694bb 38 38 .ToTable("PHRequests"); 39 39 40 modelBuilder.Entity<PharmacyHead>() 41 .Property(p => p.Id) 42 .ValueGeneratedOnAdd(); 43 40 44 /*modelBuilder.Entity<Medicine>() 41 45 .Property(x => x.Id) … … 74 78 .WithMany(p => p.Pharmacy); 75 79 */ 76 80 77 81 base.OnModelCreating(modelBuilder); 78 82 } -
FarmatikoData/FarmatikoRepo/Repository.cs
rac51326 r0a694bb 71 71 Address = x.Address, 72 72 WorkAllTime = x.WorkAllTime, 73 PheadId = x.PheadId 73 PheadId = x.PheadId, 74 PharmacyHead = x.PharmacyHead 74 75 }).Take(5).ToListAsync(); 75 76 return Pharmacies; … … 91 92 { 92 93 var SearchQuery = await _context.HealthFacilities 93 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)94 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 94 95 .OrderBy(x => x.Name).ToListAsync(); 95 96 … … 100 101 { 101 102 var SearchQuery = await _context.Medicines 102 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)103 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 103 104 .OrderBy(x => x.Name).ToListAsync(); 104 105 … … 109 110 { 110 111 var SearchQuery = await _context.Pharmacies 111 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)112 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 112 113 .OrderBy(x => x.Name).ToListAsync(); 113 114 … … 118 119 { 119 120 var SearchQuery = await _context.HealthcareWorkers 120 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)121 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 121 122 .OrderBy(x => x.Name).ToListAsync(); 122 123 … … 154 155 if (pharmacyHead.Id == 0) 155 156 { 156 var pheads = await _context.PharmacyHeads.ToListAsync(); 157 if (!pheads.Select(x => x.Equals(pharmacyHead)).FirstOrDefault()) 157 var pheads = await _context.PharmacyHeads.Select(x => new PharmacyHead 158 { 159 Name = x.Name, 160 Email = x.Email 161 }).ToListAsync(); 162 var pheadusr = pheads.Where(x => x.Email.Equals(pharmacyHead.Email)).ToList(); 163 if (pheadusr == null || pheadusr.Count() == 0) 158 164 { 159 165 await _context.PharmacyHeads.AddAsync(pharmacyHead); … … 285 291 } 286 292 287 public async Task AddUser(User user)293 public async Task<bool> AddUser(User user) 288 294 { 289 295 if (user.Id == 0) 290 296 { 291 var users = await _context.Users.ToListAsync(); 292 if (!users.Select(x => x.Equals(user)).FirstOrDefault()) 297 var users = await _context.Users.Select(x => new User 298 { 299 Name = x.Name, 300 Email = x.Email, 301 Password = x.Password, 302 UserRole = x.UserRole 303 }).ToListAsync(); 304 var usr = users.Where(x => x.Email.Equals(user.Email)).ToList(); 305 if (usr != null || usr.Count() > 0) 306 { 307 return true; 308 } 309 else 293 310 { 294 311 await _context.Users.AddAsync(user); 295 312 await _context.SaveChangesAsync(); 313 return true; 296 314 } 297 315 } 316 return false; 298 317 } 299 318 300 319 public async Task<List<PharmacyHeadMedicine>> GetAllPHMedicines() 301 320 { 302 var list = await _context.PharmacyHeadMedicines.ToListAsync(); 321 var list = await _context.PharmacyHeadMedicines.Select(x => new PharmacyHeadMedicine 322 { 323 PheadId = x.PheadId, 324 Head = x.Head, 325 MedicineId = x.MedicineId, 326 Medicine = x.Medicine 327 } 328 ).ToListAsync(); 303 329 return list; 304 330 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
rac51326 r0a694bb 46 46 User GetRole(string userName); 47 47 ICollection<PharmacyHeadMedicine> GetPHMedicines(string email); 48 Task AddUser(User user);48 Task<bool> AddUser(User user); 49 49 } 50 50 } -
FarmatikoData/Migrations/20210205174704_Initial-Migration.Designer.cs
rac51326 r0a694bb 11 11 { 12 12 [DbContext(typeof(FarmatikoDataContext))] 13 [Migration("20210 124191844_InitialMigration")]13 [Migration("20210205174704_Initial-Migration")] 14 14 partial class InitialMigration 15 15 { … … 101 101 .ValueGeneratedOnAdd() 102 102 .HasColumnType("integer") 103 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")104 103 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 105 104 … … 188 187 .ValueGeneratedOnAdd() 189 188 .HasColumnType("integer") 190 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")191 189 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 192 190 … … 230 228 .ValueGeneratedOnAdd() 231 229 .HasColumnType("integer") 232 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")233 230 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 234 231 … … 251 248 .HasColumnType("text"); 252 249 253 b.Property<int ?>("UserId")254 .HasColumnType("integer"); 255 256 b.HasKey("Id"); 257 258 b.HasIndex("UserI d");250 b.Property<int>("UserID") 251 .HasColumnType("integer"); 252 253 b.HasKey("Id"); 254 255 b.HasIndex("UserID"); 259 256 260 257 b.ToTable("PharmacyHeads"); … … 266 263 .ValueGeneratedOnAdd() 267 264 .HasColumnType("integer") 268 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")269 265 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 270 266 … … 298 294 .ValueGeneratedOnAdd() 299 295 .HasColumnType("integer") 300 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")301 296 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 302 297 … … 375 370 b.HasOne("FarmatikoData.Models.User", "User") 376 371 .WithMany() 377 .HasForeignKey("UserId"); 372 .HasForeignKey("UserID") 373 .OnDelete(DeleteBehavior.Cascade) 374 .IsRequired(); 378 375 }); 379 376 -
FarmatikoData/Migrations/20210205174704_Initial-Migration.cs
rac51326 r0a694bb 15 15 Id = table.Column<int>(nullable: false) 16 16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 17 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: 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), … … 125 125 Name = table.Column<string>(nullable: false), 126 126 Password = table.Column<string>(nullable: false), 127 UserI d = table.Column<int>(nullable: true)127 UserID = table.Column<int>(nullable: false) 128 128 }, 129 129 constraints: table => … … 131 131 table.PrimaryKey("PK_PharmacyHeads", x => x.Id); 132 132 table.ForeignKey( 133 name: "FK_PharmacyHeads_Users_UserI d",134 column: x => x.UserI d,133 name: "FK_PharmacyHeads_Users_UserID", 134 column: x => x.UserID, 135 135 principalTable: "Users", 136 136 principalColumn: "Id", 137 onDelete: ReferentialAction. Restrict);137 onDelete: ReferentialAction.Cascade); 138 138 }); 139 139 … … 172 172 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"), 173 173 DeletedOn = table.Column<DateTime>(nullable: true), 174 PheadId = table.Column<int>(nullable: true),174 PheadId = table.Column<int>(nullable: false), 175 175 HeadId = table.Column<int>(nullable: true), 176 MedicineId = table.Column<int>(nullable: true)176 MedicineId = table.Column<int>(nullable: false) 177 177 }, 178 178 constraints: table => … … 242 242 243 243 migrationBuilder.CreateIndex( 244 name: "IX_PharmacyHeads_UserI d",244 name: "IX_PharmacyHeads_UserID", 245 245 table: "PharmacyHeads", 246 column: "UserI d");246 column: "UserID"); 247 247 248 248 migrationBuilder.CreateIndex( -
FarmatikoData/Migrations/FarmatikoDataContextModelSnapshot.cs
rac51326 r0a694bb 99 99 .ValueGeneratedOnAdd() 100 100 .HasColumnType("integer") 101 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")102 101 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 103 102 … … 186 185 .ValueGeneratedOnAdd() 187 186 .HasColumnType("integer") 188 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")189 187 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 190 188 … … 228 226 .ValueGeneratedOnAdd() 229 227 .HasColumnType("integer") 230 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")231 228 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 232 229 … … 249 246 .HasColumnType("text"); 250 247 251 b.Property<int ?>("UserId")252 .HasColumnType("integer"); 253 254 b.HasKey("Id"); 255 256 b.HasIndex("UserI d");248 b.Property<int>("UserID") 249 .HasColumnType("integer"); 250 251 b.HasKey("Id"); 252 253 b.HasIndex("UserID"); 257 254 258 255 b.ToTable("PharmacyHeads"); … … 264 261 .ValueGeneratedOnAdd() 265 262 .HasColumnType("integer") 266 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")267 263 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 268 264 … … 296 292 .ValueGeneratedOnAdd() 297 293 .HasColumnType("integer") 298 .HasAnnotation("Npgsql:IdentitySequenceOptions", "'1', '1', '', '', 'False', '1'")299 294 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); 300 295 … … 373 368 b.HasOne("FarmatikoData.Models.User", "User") 374 369 .WithMany() 375 .HasForeignKey("UserId"); 370 .HasForeignKey("UserID") 371 .OnDelete(DeleteBehavior.Cascade) 372 .IsRequired(); 376 373 }); 377 374 -
FarmatikoData/Models/Medicine.cs
rac51326 r0a694bb 23 23 public string Packaging { get; set; } 24 24 //[JsonPropertyName("PHMedicineList")] 25 public ICollection<PharmacyHeadMedicine> Medicines { get; set; }25 public virtual 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
rac51326 r0a694bb 5 5 using FarmatikoData.Base; 6 6 using Microsoft.EntityFrameworkCore; 7 using Newtonsoft.Json; 7 8 8 9 namespace FarmatikoData.Models … … 12 13 public Pharmacy() { } 13 14 [Required] 15 [JsonProperty("name")] 14 16 public string Name { get; set; } 15 17 [Required] 18 [JsonProperty("location")] 16 19 public string Location { get; set; } 17 20 [Required] 21 [JsonProperty("address")] 18 22 public string Address { get; set; } 19 23 [Required] 24 [JsonProperty("workAllTime")] 20 25 public bool WorkAllTime { get; set; } 21 26 public Pharmacy(string Name, string Location, string Address, bool WorkAllTime) -
FarmatikoData/Models/PharmacyHead.cs
rac51326 r0a694bb 24 24 public virtual List<Pharmacy> Pharmacies { get; set; } 25 25 public virtual List<PharmacyHeadMedicine> Medicines { get; set; } 26 26 27 public int UserID { get; set; } 27 28 public User User { get; set; } 28 29
Note:
See TracChangeset
for help on using the changeset viewer.