Changeset 1db5673 for FarmatikoData


Ignore:
Timestamp:
11/14/20 12:27:30 (3 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
68454c6
Parents:
ad60966
Message:

Fix bugs, add some more

Location:
FarmatikoData
Files:
1 added
1 deleted
12 edited
2 moved

Legend:

Unmodified
Added
Removed
  • FarmatikoData/Base/BaseEntity.cs

    rad60966 r1db5673  
    33using System.Text;
    44using System.ComponentModel.DataAnnotations;
     5using System.Text.Json.Serialization;
    56
    67namespace FarmatikoData.Base
     
    89    public class BaseEntity
    910    {
    10         public int Id { get; set; }
     11        [JsonPropertyName("id")]
     12        public int Id {  get; set; }
    1113        public DateTime CreatedOn { get; set; }
    1214        public DateTime? DeletedOn { get; set; }
  • FarmatikoData/FarmatikoData.csproj

    rad60966 r1db5673  
    66
    77  <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">
    911      <PrivateAssets>all</PrivateAssets>
    1012      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    1113    </PackageReference>
    12     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.6">
     14    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.10">
    1315      <PrivateAssets>all</PrivateAssets>
    1416      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  • FarmatikoData/FarmatikoDataContext.cs

    rad60966 r1db5673  
    1515        public virtual DbSet<Pandemic> Pandemics { get; set; }
    1616        public virtual DbSet<Medicine> Medicines { get; set; }
    17         //public virtual DbSet<MedicineList> MedicineLists { get; set; }
    1817        public virtual DbSet<RequestPharmacyHead> PHRequests { get; set; }
    1918        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        }
    2048    }
    2149}
  • FarmatikoData/FarmatikoRepo/PHRepo.cs

    rad60966 r1db5673  
    3131                    Email = x.Email,
    3232                    Password = x.Password,
    33                     MedicineLists = x.MedicineLists,
     33                    MedicineList = x.MedicineList,
    3434                    PharmaciesList = x.PharmaciesList
    3535                }).ToListAsync();
     
    3939        public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead)
    4040        {
    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();
    4243            EditedPHead.Email = pharmacyHead.Email;
    4344            EditedPHead.Name = pharmacyHead.Name;
    4445            EditedPHead.Password = pharmacyHead.Password;
    45             EditedPHead.MedicineLists = pharmacyHead.MedicineLists;
     46            /*if (pharmacyHead.MedicineList.Count() == 0)
     47                pharmacyHead.MedicineList = null;*/
     48            EditedPHead.MedicineList = pharmacyHead.MedicineList;
    4649            EditedPHead.PharmaciesList = pharmacyHead.PharmaciesList;
     50            EditedPHead.PHMedicineList = pharmacyHead.PHMedicineList;
     51            //_context.Entry<PharmacyHead>(Phead).State = EntityState.Detached;
     52            Phead = EditedPHead;
    4753            await _context.SaveChangesAsync();
    4854        }
     
    7278        }
    7379
     80
    7481        public PharmacyHead GetPharmacyHeadByUserName(string userName)
    7582        {
    76             return _context.PharmacyHeads
     83            var PHead = _context.PharmacyHeads
    7784                .Where(x => x.Email.Equals(userName))
    7885                .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;
    79120        }
    80121    }
  • FarmatikoData/FarmatikoRepo/Repository.cs

    rad60966 r1db5673  
    4141        }
    4242
    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();
    4656            return Medicines;
    4757        }
     
    205215        public Task UpdateMedicine(Medicine medicine)
    206216        {
    207             throw new System.NotImplementedException();
     217            throw new NotImplementedException();
    208218        }
    209219
     
    227237            return users;
    228238        }
     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        }
    229270    }
    230271}
  • FarmatikoData/FarmatikoRepoInterfaces/IPHRepo.cs

    rad60966 r1db5673  
    1818        Task RemoveClaimingRequest(int id);
    1919        PharmacyHead GetPharmacyHeadByUserName(string userName);
     20        List<PharmacyHeadMedicine> GetPharmacyHeadMedicines(string email);
     21        IEnumerable<PharmacyHead> GetPharmacyHeads();
     22        PharmacyHead GetPharmacyHead(string head);
     23        List<Pharmacy> GetPharmacies();
    2024    }
    2125}
  • FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs

    rad60966 r1db5673  
    1515        Task<HealthFacility> GetFacility(int Id);
    1616        Task<Medicine> GetMedicine(int Id);
    17         Task<IEnumerable<Medicine>> GetMedicines();
     17        Task<IEnumerable<Medicine>> GetMedicinesAsync();
     18        ICollection<Medicine> GetMedicines();
    1819        Task<Pandemic> GetPandemic();
    1920        Task<IEnumerable<Pharmacy>> GetPharmacies();
     
    4243        Task UpdateMedicine(Medicine medicine);
    4344        Task RemovePharmacyHead(int Id);
     45        User GetRole(string userName);
     46        ICollection<PharmacyHeadMedicine> GetPHMedicines(string email);
    4447    }
    4548}
  • FarmatikoData/Migrations/20201111183247_InitialMigration.Designer.cs

    rad60966 r1db5673  
    1111{
    1212    [DbContext(typeof(FarmatikoDataContext))]
    13     [Migration("20201105063549_InitialMigration")]
     13    [Migration("20201111183247_InitialMigration")]
    1414    partial class InitialMigration
    1515    {
     
    123123                        .HasColumnType("text");
    124124
     125                    b.Property<int?>("PharmacyHeadId")
     126                        .HasColumnType("integer");
     127
    125128                    b.Property<float>("Price")
    126129                        .HasColumnType("real");
     
    136139                    b.HasKey("Id");
    137140
     141                    b.HasIndex("PharmacyHeadId");
     142
    138143                    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");
    170144                });
    171145
     
    238212                        .HasColumnType("text");
    239213
    240                     b.Property<int?>("PharmacyHeadId")
     214                    b.Property<int>("PheadId")
    241215                        .HasColumnType("integer");
    242216
     
    246220                    b.HasKey("Id");
    247221
    248                     b.HasIndex("PharmacyHeadId");
     222                    b.HasIndex("PheadId");
    249223
    250224                    b.ToTable("Pharmacies");
     
    279253
    280254                    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");
    281279                });
    282280
     
    348346                });
    349347
    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 =>
    351365                {
    352366                    b.HasOne("FarmatikoData.Models.Medicine", "Medicine")
    353                         .WithMany()
     367                        .WithMany("MedicineList")
    354368                        .HasForeignKey("MedicineId")
    355369                        .OnDelete(DeleteBehavior.Cascade)
    356370                        .IsRequired();
    357371
    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();
    368377                });
    369378
  • FarmatikoData/Migrations/20201111183247_InitialMigration.cs

    rad60966 r1db5673  
    1515                    Id = table.Column<int>(nullable: false)
    1616                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    17                     CreatedOn = table.Column<DateTime>(nullable: false),
     17                    CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    1818                    DeletedOn = table.Column<DateTime>(nullable: true),
    1919                    Name = table.Column<string>(nullable: false),
     
    3030
    3131            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(
    5332                name: "Pandemics",
    5433                columns: table => new
     
    5635                    Id = table.Column<int>(nullable: false)
    5736                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    58                     CreatedOn = table.Column<DateTime>(nullable: false),
     37                    CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    5938                    DeletedOn = table.Column<DateTime>(nullable: true),
    6039                    Name = table.Column<string>(nullable: false),
     
    7857                    Id = table.Column<int>(nullable: false)
    7958                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    80                     CreatedOn = table.Column<DateTime>(nullable: false),
     59                    CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    8160                    DeletedOn = table.Column<DateTime>(nullable: true),
    8261                    Email = table.Column<string>(nullable: false),
     
    9574                    Id = table.Column<int>(nullable: false)
    9675                        .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),
    10281                    UserRole = table.Column<int>(nullable: false)
    10382                },
     
    11392                    Id = table.Column<int>(nullable: false)
    11493                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    115                     CreatedOn = table.Column<DateTime>(nullable: false),
     94                    CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    11695                    DeletedOn = table.Column<DateTime>(nullable: true),
    11796                    Name = table.Column<string>(nullable: false),
     
    132111
    133112            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),
    143127                    PharmacyHeadId = table.Column<int>(nullable: true)
    144128                },
    145129                constraints: table =>
    146130                {
    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",
    156134                        column: x => x.PharmacyHeadId,
    157135                        principalTable: "PharmacyHeads",
     
    172150                    Address = table.Column<string>(nullable: false),
    173151                    WorkAllTime = table.Column<bool>(nullable: false),
    174                     PharmacyHeadId = table.Column<int>(nullable: true)
     152                    PheadId = table.Column<int>(nullable: false)
    175153                },
    176154                constraints: table =>
     
    178156                    table.PrimaryKey("PK_Pharmacies", x => x.Id);
    179157                    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);
    185190                });
    186191
     
    191196                    Id = table.Column<int>(nullable: false)
    192197                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    193                     CreatedOn = table.Column<DateTime>(nullable: false),
     198                    CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    194199                    DeletedOn = table.Column<DateTime>(nullable: true),
    195200                    HeadId = table.Column<int>(nullable: false),
     
    219224
    220225            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",
    223238                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");
    234239
    235240            migrationBuilder.CreateIndex(
     
    250255
    251256            migrationBuilder.DropTable(
    252                 name: "MedicineList");
    253 
    254             migrationBuilder.DropTable(
    255257                name: "Pandemics");
     258
     259            migrationBuilder.DropTable(
     260                name: "PharmacyHeadMedicines");
    256261
    257262            migrationBuilder.DropTable(
  • FarmatikoData/Migrations/FarmatikoDataContextModelSnapshot.cs

    rad60966 r1db5673  
    121121                        .HasColumnType("text");
    122122
     123                    b.Property<int?>("PharmacyHeadId")
     124                        .HasColumnType("integer");
     125
    123126                    b.Property<float>("Price")
    124127                        .HasColumnType("real");
     
    134137                    b.HasKey("Id");
    135138
     139                    b.HasIndex("PharmacyHeadId");
     140
    136141                    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");
    168142                });
    169143
     
    236210                        .HasColumnType("text");
    237211
    238                     b.Property<int?>("PharmacyHeadId")
     212                    b.Property<int>("PheadId")
    239213                        .HasColumnType("integer");
    240214
     
    244218                    b.HasKey("Id");
    245219
    246                     b.HasIndex("PharmacyHeadId");
     220                    b.HasIndex("PheadId");
    247221
    248222                    b.ToTable("Pharmacies");
     
    277251
    278252                    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");
    279277                });
    280278
     
    346344                });
    347345
    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 =>
    349363                {
    350364                    b.HasOne("FarmatikoData.Models.Medicine", "Medicine")
    351                         .WithMany()
     365                        .WithMany("MedicineList")
    352366                        .HasForeignKey("MedicineId")
    353367                        .OnDelete(DeleteBehavior.Cascade)
    354368                        .IsRequired();
    355369
    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();
    366375                });
    367376
  • FarmatikoData/Models/Medicine.cs

    rad60966 r1db5673  
    11using FarmatikoData.Base;
     2using System.Collections;
     3using System.Collections.Generic;
    24using System.ComponentModel.DataAnnotations;
     5using System.Diagnostics.CodeAnalysis;
     6using System.Text.Json.Serialization;
    37
    48namespace FarmatikoData.Models
     
    1822        public float Price { get; set; }
    1923        public string Packaging { get; set; }
     24        //[JsonPropertyName("PHMedicineList")]
     25        public ICollection<PharmacyHeadMedicine> MedicineList { get; set; }
    2026        public Medicine(string Name, string Strength, string Form, string WayOfIssuing, string Manufacturer, float Price, string Packaging)
    2127        {
     
    2834            this.Packaging = Packaging;
    2935        }
    30 
    3136    }
    3237}
  • FarmatikoData/Models/Pharmacy.cs

    rad60966 r1db5673  
    2626            this.WorkAllTime = WorkAllTime;
    2727        }
     28        public int PheadId { get; set; }
     29        public PharmacyHead PHead { get; set; }
    2830    }
    2931}
  • FarmatikoData/Models/PharmacyHead.cs

    rad60966 r1db5673  
    11using System.Collections.Generic;
    22using System.ComponentModel.DataAnnotations;
     3using System.Text.Json.Serialization;
    34using FarmatikoData.Base;
     5using Newtonsoft.Json;
    46
    57namespace FarmatikoData.Models
     
    1113        }
    1214        [Required]
     15        [JsonProperty("Email")]
    1316        public string Email { get; set; }
    1417        [Required]
     18        [JsonProperty("Name")]
    1519        public string Name { get; set; }
    1620        [Required]
     21        [JsonProperty("Passwd")]
    1722        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; }
    2030
    2131    }
  • FarmatikoData/Models/RequestPharmacyHead.cs

    rad60966 r1db5673  
    44using System.ComponentModel.DataAnnotations;
    55using System.Text;
     6using System.Text.Json.Serialization;
    67
    78namespace FarmatikoData.Models
     
    1314        }
    1415        [Required]
     16        [JsonPropertyName("PharmacyHead")]
    1517        public PharmacyHead Head { get; set; }
    1618        [Required]
     19        [JsonPropertyName("Pharmacy")]
    1720        public Pharmacy Pharmacy { get; set; }
    1821
Note: See TracChangeset for help on using the changeset viewer.