Przeglądaj źródła

Add Consent to Timeshare Buy and Sell and ContactUs

master
Brian Conway 2 lat temu
rodzic
commit
65f10302f1
25 zmienionych plików z 9899 dodań i 53 usunięć
  1. 1
    0
      UnivateProperties_API/Containers/ProcessFlow/BidItemDisplay.cs
  2. 2
    0
      UnivateProperties_API/Containers/Timeshare/WeekDto.cs
  3. 4
    1
      UnivateProperties_API/Context/DataContext.cs
  4. 64
    0
      UnivateProperties_API/Controllers/Communication/MailSourceController.cs
  5. 4
    5
      UnivateProperties_API/Migrations/20220720084941_MailModel.Designer.cs
  6. 3
    4
      UnivateProperties_API/Migrations/20220720084941_MailModel.cs
  7. 1898
    0
      UnivateProperties_API/Migrations/20220721092254_MailSources.Designer.cs
  8. 63
    0
      UnivateProperties_API/Migrations/20220721092254_MailSources.cs
  9. 1898
    0
      UnivateProperties_API/Migrations/20220804103536_ContactUsMailSourceDescription.Designer.cs
  10. 17
    0
      UnivateProperties_API/Migrations/20220804103536_ContactUsMailSourceDescription.cs
  11. 1900
    0
      UnivateProperties_API/Migrations/20220829091410_addConsentCommunicationAndWeeks.Designer.cs
  12. 23
    0
      UnivateProperties_API/Migrations/20220829091410_addConsentCommunicationAndWeeks.cs
  13. 1902
    0
      UnivateProperties_API/Migrations/20220829091928_AddConsentTimeshareWeek.Designer.cs
  14. 23
    0
      UnivateProperties_API/Migrations/20220829091928_AddConsentTimeshareWeek.cs
  15. 1904
    0
      UnivateProperties_API/Migrations/20220830051240_BidItemAddConsent.Designer.cs
  16. 23
    0
      UnivateProperties_API/Migrations/20220830051240_BidItemAddConsent.cs
  17. 10
    5
      UnivateProperties_API/Migrations/DataContextModelSnapshot.cs
  18. 2
    1
      UnivateProperties_API/Model/Communication/MailModel.cs
  19. 1
    1
      UnivateProperties_API/Model/Communication/MailSource.cs
  20. 2
    0
      UnivateProperties_API/Model/ProcessFlow/BidItem.cs
  21. 1
    0
      UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs
  22. 56
    35
      UnivateProperties_API/Repository/Communication/MailRepository.cs
  23. 96
    0
      UnivateProperties_API/Repository/Communication/MailSourceRepository.cs
  24. 1
    1
      UnivateProperties_API/Startup.cs
  25. 1
    0
      UnivateProperties_API/appsettings.json

+ 1
- 0
UnivateProperties_API/Containers/ProcessFlow/BidItemDisplay.cs Wyświetl plik

20
         public string MadeBy { get; set; }
20
         public string MadeBy { get; set; }
21
         public DateTime Date { get; set; }
21
         public DateTime Date { get; set; }
22
         public string Comment { get; set; }
22
         public string Comment { get; set; }
23
+        public bool Consent { get; set; }
23
         public string DeclineReason { get; set; }
24
         public string DeclineReason { get; set; }
24
         public decimal SellPrice { get; set; }
25
         public decimal SellPrice { get; set; }
25
         #endregion 
26
         #endregion 

+ 2
- 0
UnivateProperties_API/Containers/Timeshare/WeekDto.cs Wyświetl plik

139
             Publish = week.Publish;
139
             Publish = week.Publish;
140
             PulbishedDate = week.PulbishedDate;
140
             PulbishedDate = week.PulbishedDate;
141
             CustomOwner = week.CustomOwner;
141
             CustomOwner = week.CustomOwner;
142
+            Consent = week.Consent;
142
         }
143
         }
143
 
144
 
144
         public int Id { get; set; }
145
         public int Id { get; set; }
175
         public bool Publish { get; set; }
176
         public bool Publish { get; set; }
176
         public DateTime PulbishedDate { get; set; }
177
         public DateTime PulbishedDate { get; set; }
177
         public bool CustomOwner {get; set;}
178
         public bool CustomOwner {get; set;}
179
+        public bool Consent { get; set; }
178
     }
180
     }
179
 }
181
 }

+ 4
- 1
UnivateProperties_API/Context/DataContext.cs Wyświetl plik

19
     public class DataContext : DbContext
19
     public class DataContext : DbContext
20
     {
20
     {
21
         private string connectionString = "";
21
         private string connectionString = "";
22
+        internal object BidItem;
23
+
22
         public DataContext(DbContextOptions<DataContext> options) : base(options)
24
         public DataContext(DbContextOptions<DataContext> options) : base(options)
23
         {
25
         {
24
             foreach (var extention in options.Extensions)
26
             foreach (var extention in options.Extensions)
59
         public virtual DbSet<PlaceHolder> PlaceHolders { get; set; }
61
         public virtual DbSet<PlaceHolder> PlaceHolders { get; set; }
60
         public virtual DbSet<MailRecipient> MailRecipients { get; set; }
62
         public virtual DbSet<MailRecipient> MailRecipients { get; set; }
61
         public virtual DbSet<MailModel> CommunicationLog { get; set; }
63
         public virtual DbSet<MailModel> CommunicationLog { get; set; }
62
-        public virtual DbSet<MailSource> MailSource { get; set; }
64
+        public virtual DbSet<MailSource> MailSources { get; set; }
63
         #endregion Communication
65
         #endregion Communication
64
 
66
 
65
         #region Property
67
         #region Property
220
             modelBuilder.Entity<CampaignItemPlaceHolder>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
222
             modelBuilder.Entity<CampaignItemPlaceHolder>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
221
             modelBuilder.Entity<CampaignPlaceHolder>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
223
             modelBuilder.Entity<CampaignPlaceHolder>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
222
             modelBuilder.Entity<PlaceHolderFormat>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
224
             modelBuilder.Entity<PlaceHolderFormat>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
225
+            modelBuilder.Entity<MailSource>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
223
         }
226
         }
224
 
227
 
225
 
228
 

+ 64
- 0
UnivateProperties_API/Controllers/Communication/MailSourceController.cs Wyświetl plik

1
+using System.Transactions;
2
+using Microsoft.AspNetCore.Mvc;
3
+using UnivateProperties_API.Model.Communication;
4
+using UnivateProperties_API.Repository;
5
+
6
+namespace UnivateProperties_API.Controllers.Communication
7
+{
8
+    [Route("api/[controller]")]
9
+    [ApiController]
10
+    public class MailSourceController : ControllerBase
11
+    {
12
+        private readonly IRepository<MailSource> _Repo;
13
+
14
+        public MailSourceController(IRepository<MailSource> repo)
15
+        {
16
+            _Repo = repo;
17
+        }
18
+
19
+        [HttpGet]
20
+        public IActionResult Get()
21
+        {
22
+            return new OkObjectResult(_Repo.GetAll());
23
+        }
24
+
25
+        [HttpGet("{id}")]
26
+        public IActionResult Get(int id)
27
+        {
28
+            return new OkObjectResult(_Repo.GetDetailed(x => x.Id == id));
29
+        }
30
+
31
+        [HttpPost]
32
+        public IActionResult Post([FromBody] MailSource mailSource)
33
+        {
34
+            using (var scope = new TransactionScope())
35
+            {
36
+                _Repo.Insert(mailSource);
37
+                scope.Complete();
38
+                return CreatedAtAction(nameof(Get), new { id = mailSource.Id }, mailSource);
39
+            }
40
+        }
41
+
42
+        [HttpPut]
43
+        public IActionResult Put([FromBody] MailSource mailSource)
44
+        {
45
+            if (mailSource != null)
46
+            {
47
+                using (var scope = new TransactionScope())
48
+                {
49
+                    _Repo.Update(mailSource);
50
+                    scope.Complete();
51
+                    return new OkResult();
52
+                }
53
+            }
54
+            return new NoContentResult();
55
+        }
56
+
57
+        [HttpDelete("{id}")]
58
+        public IActionResult Delete(int id)
59
+        {
60
+            _Repo.RemoveAtId(id);
61
+            return new OkResult();
62
+        }
63
+    }
64
+}

UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.Designer.cs → UnivateProperties_API/Migrations/20220720084941_MailModel.Designer.cs Wyświetl plik

10
 namespace UnivateProperties_API.Migrations
10
 namespace UnivateProperties_API.Migrations
11
 {
11
 {
12
     [DbContext(typeof(DataContext))]
12
     [DbContext(typeof(DataContext))]
13
-    [Migration("20220714125536_MailSource-MailModel")]
14
-    partial class MailSourceMailModel
13
+    [Migration("20220720084941_MailModel")]
14
+    partial class MailModel
15
     {
15
     {
16
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
16
         protected override void BuildTargetModel(ModelBuilder modelBuilder)
17
         {
17
         {
318
 
318
 
319
                     b.Property<bool>("IsDeleted");
319
                     b.Property<bool>("IsDeleted");
320
 
320
 
321
-                    b.Property<int>("MailSourceId");
321
+                    b.Property<int?>("MailSourceId");
322
 
322
 
323
                     b.Property<string>("Message");
323
                     b.Property<string>("Message");
324
 
324
 
1670
                 {
1670
                 {
1671
                     b.HasOne("UnivateProperties_API.Model.Communication.MailSource", "MailSource")
1671
                     b.HasOne("UnivateProperties_API.Model.Communication.MailSource", "MailSource")
1672
                         .WithMany("MailModels")
1672
                         .WithMany("MailModels")
1673
-                        .HasForeignKey("MailSourceId")
1674
-                        .OnDelete(DeleteBehavior.Cascade);
1673
+                        .HasForeignKey("MailSourceId");
1675
                 });
1674
                 });
1676
 
1675
 
1677
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
1676
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>

UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.cs → UnivateProperties_API/Migrations/20220720084941_MailModel.cs Wyświetl plik

2
 
2
 
3
 namespace UnivateProperties_API.Migrations
3
 namespace UnivateProperties_API.Migrations
4
 {
4
 {
5
-    public partial class MailSourceMailModel : Migration
5
+    public partial class MailModel : Migration
6
     {
6
     {
7
         protected override void Up(MigrationBuilder migrationBuilder)
7
         protected override void Up(MigrationBuilder migrationBuilder)
8
         {
8
         {
9
             migrationBuilder.AddColumn<int>(
9
             migrationBuilder.AddColumn<int>(
10
                 name: "MailSourceId",
10
                 name: "MailSourceId",
11
                 table: "CommunicationLog",
11
                 table: "CommunicationLog",
12
-                nullable: false,
13
-                defaultValue: 0);
12
+                nullable: true);
14
 
13
 
15
             migrationBuilder.CreateIndex(
14
             migrationBuilder.CreateIndex(
16
                 name: "IX_CommunicationLog_MailSourceId",
15
                 name: "IX_CommunicationLog_MailSourceId",
23
                 column: "MailSourceId",
22
                 column: "MailSourceId",
24
                 principalTable: "MailSource",
23
                 principalTable: "MailSource",
25
                 principalColumn: "Id",
24
                 principalColumn: "Id",
26
-                onDelete: ReferentialAction.Cascade);
25
+                onDelete: ReferentialAction.Restrict);
27
         }
26
         }
28
 
27
 
29
         protected override void Down(MigrationBuilder migrationBuilder)
28
         protected override void Down(MigrationBuilder migrationBuilder)

+ 1898
- 0
UnivateProperties_API/Migrations/20220721092254_MailSources.Designer.cs
Plik diff jest za duży
Wyświetl plik


+ 63
- 0
UnivateProperties_API/Migrations/20220721092254_MailSources.cs Wyświetl plik

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class MailSources : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.DropForeignKey(
10
+                name: "FK_CommunicationLog_MailSource_MailSourceId",
11
+                table: "CommunicationLog");
12
+
13
+            migrationBuilder.DropPrimaryKey(
14
+                name: "PK_MailSource",
15
+                table: "MailSource");
16
+
17
+            migrationBuilder.RenameTable(
18
+                name: "MailSource",
19
+                newName: "MailSources");
20
+
21
+            migrationBuilder.AddPrimaryKey(
22
+                name: "PK_MailSources",
23
+                table: "MailSources",
24
+                column: "Id");
25
+
26
+            migrationBuilder.AddForeignKey(
27
+                name: "FK_CommunicationLog_MailSources_MailSourceId",
28
+                table: "CommunicationLog",
29
+                column: "MailSourceId",
30
+                principalTable: "MailSources",
31
+                principalColumn: "Id",
32
+                onDelete: ReferentialAction.Restrict);
33
+        }
34
+
35
+        protected override void Down(MigrationBuilder migrationBuilder)
36
+        {
37
+            migrationBuilder.DropForeignKey(
38
+                name: "FK_CommunicationLog_MailSources_MailSourceId",
39
+                table: "CommunicationLog");
40
+
41
+            migrationBuilder.DropPrimaryKey(
42
+                name: "PK_MailSources",
43
+                table: "MailSources");
44
+
45
+            migrationBuilder.RenameTable(
46
+                name: "MailSources",
47
+                newName: "MailSource");
48
+
49
+            migrationBuilder.AddPrimaryKey(
50
+                name: "PK_MailSource",
51
+                table: "MailSource",
52
+                column: "Id");
53
+
54
+            migrationBuilder.AddForeignKey(
55
+                name: "FK_CommunicationLog_MailSource_MailSourceId",
56
+                table: "CommunicationLog",
57
+                column: "MailSourceId",
58
+                principalTable: "MailSource",
59
+                principalColumn: "Id",
60
+                onDelete: ReferentialAction.Restrict);
61
+        }
62
+    }
63
+}

+ 1898
- 0
UnivateProperties_API/Migrations/20220804103536_ContactUsMailSourceDescription.Designer.cs
Plik diff jest za duży
Wyświetl plik


+ 17
- 0
UnivateProperties_API/Migrations/20220804103536_ContactUsMailSourceDescription.cs Wyświetl plik

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class ContactUsMailSourceDescription : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+
10
+        }
11
+
12
+        protected override void Down(MigrationBuilder migrationBuilder)
13
+        {
14
+
15
+        }
16
+    }
17
+}

+ 1900
- 0
UnivateProperties_API/Migrations/20220829091410_addConsentCommunicationAndWeeks.Designer.cs
Plik diff jest za duży
Wyświetl plik


+ 23
- 0
UnivateProperties_API/Migrations/20220829091410_addConsentCommunicationAndWeeks.cs Wyświetl plik

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class addConsentCommunicationAndWeeks : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<bool>(
10
+                name: "Consent",
11
+                table: "CommunicationLog",
12
+                nullable: false,
13
+                defaultValue: false);
14
+        }
15
+
16
+        protected override void Down(MigrationBuilder migrationBuilder)
17
+        {
18
+            migrationBuilder.DropColumn(
19
+                name: "Consent",
20
+                table: "CommunicationLog");
21
+        }
22
+    }
23
+}

+ 1902
- 0
UnivateProperties_API/Migrations/20220829091928_AddConsentTimeshareWeek.Designer.cs
Plik diff jest za duży
Wyświetl plik


+ 23
- 0
UnivateProperties_API/Migrations/20220829091928_AddConsentTimeshareWeek.cs Wyświetl plik

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class AddConsentTimeshareWeek : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<bool>(
10
+                name: "Consent",
11
+                table: "Weeks",
12
+                nullable: false,
13
+                defaultValue: false);
14
+        }
15
+
16
+        protected override void Down(MigrationBuilder migrationBuilder)
17
+        {
18
+            migrationBuilder.DropColumn(
19
+                name: "Consent",
20
+                table: "Weeks");
21
+        }
22
+    }
23
+}

+ 1904
- 0
UnivateProperties_API/Migrations/20220830051240_BidItemAddConsent.Designer.cs
Plik diff jest za duży
Wyświetl plik


+ 23
- 0
UnivateProperties_API/Migrations/20220830051240_BidItemAddConsent.cs Wyświetl plik

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class BidItemAddConsent : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<bool>(
10
+                name: "Consent",
11
+                table: "BidItems",
12
+                nullable: false,
13
+                defaultValue: false);
14
+        }
15
+
16
+        protected override void Down(MigrationBuilder migrationBuilder)
17
+        {
18
+            migrationBuilder.DropColumn(
19
+                name: "Consent",
20
+                table: "BidItems");
21
+        }
22
+    }
23
+}

+ 10
- 5
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs Wyświetl plik

304
 
304
 
305
                     b.Property<string>("ComType");
305
                     b.Property<string>("ComType");
306
 
306
 
307
+                    b.Property<bool>("Consent");
308
+
307
                     b.Property<DateTime>("Created");
309
                     b.Property<DateTime>("Created");
308
 
310
 
309
                     b.Property<string>("Email");
311
                     b.Property<string>("Email");
316
 
318
 
317
                     b.Property<bool>("IsDeleted");
319
                     b.Property<bool>("IsDeleted");
318
 
320
 
319
-                    b.Property<int>("MailSourceId");
321
+                    b.Property<int?>("MailSourceId");
320
 
322
 
321
                     b.Property<string>("Message");
323
                     b.Property<string>("Message");
322
 
324
 
382
 
384
 
383
                     b.HasKey("Id");
385
                     b.HasKey("Id");
384
 
386
 
385
-                    b.ToTable("MailSource");
387
+                    b.ToTable("MailSources");
386
                 });
388
                 });
387
 
389
 
388
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
390
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
747
 
749
 
748
                     b.Property<string>("Comment");
750
                     b.Property<string>("Comment");
749
 
751
 
752
+                    b.Property<bool>("Consent");
753
+
750
                     b.Property<DateTime>("Created");
754
                     b.Property<DateTime>("Created");
751
 
755
 
752
                     b.Property<string>("DeclinedReason");
756
                     b.Property<string>("DeclinedReason");
1180
 
1184
 
1181
                     b.Property<string>("Bedrooms");
1185
                     b.Property<string>("Bedrooms");
1182
 
1186
 
1187
+                    b.Property<bool>("Consent");
1188
+
1183
                     b.Property<DateTime>("Created");
1189
                     b.Property<DateTime>("Created");
1184
 
1190
 
1185
                     b.Property<bool>("CurrentYearBanked");
1191
                     b.Property<bool>("CurrentYearBanked");
1667
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.MailModel", b =>
1673
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.MailModel", b =>
1668
                 {
1674
                 {
1669
                     b.HasOne("UnivateProperties_API.Model.Communication.MailSource", "MailSource")
1675
                     b.HasOne("UnivateProperties_API.Model.Communication.MailSource", "MailSource")
1670
-                        .WithMany("MailModels")
1671
-                        .HasForeignKey("MailSourceId")
1672
-                        .OnDelete(DeleteBehavior.Cascade);
1676
+                        .WithMany()
1677
+                        .HasForeignKey("MailSourceId");
1673
                 });
1678
                 });
1674
 
1679
 
1675
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
1680
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>

+ 2
- 1
UnivateProperties_API/Model/Communication/MailModel.cs Wyświetl plik

14
         public string Message { get; set; }
14
         public string Message { get; set; }
15
         public string HeardFrom { get; set; }
15
         public string HeardFrom { get; set; }
16
         [ForeignKey("MailSource")]
16
         [ForeignKey("MailSource")]
17
-        public int MailSourceId { get; set; }
17
+        public int? MailSourceId { get; set; }
18
         public virtual MailSource MailSource { get; set; }
18
         public virtual MailSource MailSource { get; set; }
19
         public string Error { get; set; }
19
         public string Error { get; set; }
20
+        public bool Consent { get; set; }
20
     }
21
     }
21
 }
22
 }

+ 1
- 1
UnivateProperties_API/Model/Communication/MailSource.cs Wyświetl plik

8
     public class MailSource : BaseEntity
8
     public class MailSource : BaseEntity
9
     {
9
     {
10
         public string Description { get; set; }
10
         public string Description { get; set; }
11
-        public ICollection<MailModel> MailModels { get; set; }
11
+        public override string Display => Description;
12
     }
12
     }
13
 }
13
 }

+ 2
- 0
UnivateProperties_API/Model/ProcessFlow/BidItem.cs Wyświetl plik

14
         public int? PropertyId { get; set; }
14
         public int? PropertyId { get; set; }
15
         public string Comment { get; set; }
15
         public string Comment { get; set; }
16
         public string DeclinedReason { get; set; }
16
         public string DeclinedReason { get; set; }
17
+        public bool Consent { get; set; }
17
 
18
 
18
         public virtual Status Status { get; set; }
19
         public virtual Status Status { get; set; }
19
         public virtual Individual BidMaker { get; set; }
20
         public virtual Individual BidMaker { get; set; }
20
         public virtual TimeshareWeek TimeshareWeek {get;set;}
21
         public virtual TimeshareWeek TimeshareWeek {get;set;}
21
         public virtual Property Property { get; set; }
22
         public virtual Property Property { get; set; }
23
+
22
         #endregion
24
         #endregion
23
     }
25
     }
24
 }
26
 }

+ 1
- 0
UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs Wyświetl plik

107
         public string WeekStatus { get; set; }
107
         public string WeekStatus { get; set; }
108
         public bool Publish { get; set; }
108
         public bool Publish { get; set; }
109
         public DateTime PulbishedDate { get; set; }
109
         public DateTime PulbishedDate { get; set; }
110
+        public bool Consent { get; set; }
110
         #endregion
111
         #endregion
111
 
112
 
112
         #region Navigation
113
         #region Navigation

+ 56
- 35
UnivateProperties_API/Repository/Communication/MailRepository.cs Wyświetl plik

1
 using Abp.Specifications;
1
 using Abp.Specifications;
2
+using Microsoft.EntityFrameworkCore;
2
 using MimeKit;
3
 using MimeKit;
3
 using System;
4
 using System;
4
 using System.Collections.Generic;
5
 using System.Collections.Generic;
6
+using System.Dynamic;
5
 using System.Linq;
7
 using System.Linq;
6
 using System.Linq.Dynamic.Core;
8
 using System.Linq.Dynamic.Core;
7
 using System.Net.Mail;
9
 using System.Net.Mail;
33
     public class MailRepository : IMailRepository
35
     public class MailRepository : IMailRepository
34
     {
36
     {
35
         private readonly DataContext _dbContext;
37
         private readonly DataContext _dbContext;
36
-
38
+        string error;
37
         public MailRepository(DataContext db)
39
         public MailRepository(DataContext db)
38
         {
40
         {
39
             _dbContext = db;              
41
             _dbContext = db;              
47
         {            
49
         {            
48
             var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "ContactUs").Where(y => y.IsDeleted == false).ToList();            
50
             var recipients = _dbContext.MailRecipients.Where(x => x.RecipientUsage == "ContactUs").Where(y => y.IsDeleted == false).ToList();            
49
             string body = _dbContext.Templates.Where(x => x.Name == "ContactUs").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
51
             string body = _dbContext.Templates.Where(x => x.Name == "ContactUs").Where(y => y.IsDeleted == false).FirstOrDefault().Body;
50
-            string error = "";
52
+            var source = _dbContext.MailSources.Where(x => x.Id == Convert.ToInt32(mm.MailSourceId)).FirstOrDefault();
53
+
51
 
54
 
52
             body = body.Replace("[FULLNAME]", mm.Name);
55
             body = body.Replace("[FULLNAME]", mm.Name);
53
             body = body.Replace("[USEREMAIL]", mm.Email);
56
             body = body.Replace("[USEREMAIL]", mm.Email);
54
             body = body.Replace("[USERCELLPHONE]", mm.Phone);
57
             body = body.Replace("[USERCELLPHONE]", mm.Phone);
55
             body = body.Replace("[PROPERTYREF]", mm.Property);
58
             body = body.Replace("[PROPERTYREF]", mm.Property);
59
+            body = body.Replace("[SOURCE]", source.Description);
56
             body = body.Replace("[USERMESSAGE]", mm.Message);
60
             body = body.Replace("[USERMESSAGE]", mm.Message);
61
+            body = body.Replace("[USERCONSENT]", mm.Consent.ToString());
62
+
57
 
63
 
58
             string toList = "";
64
             string toList = "";
59
             int emailCount = 0;
65
             int emailCount = 0;
226
             body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
232
             body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
227
             body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
233
             body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
228
             body = body.Replace("[USERCOMMENT]", bid.Comment);
234
             body = body.Replace("[USERCOMMENT]", bid.Comment);
235
+            body = body.Replace("[USERCONSENT]", bid.Consent.ToString());
229
 
236
 
230
             string toList = "";
237
             string toList = "";
231
             int emailCount = 0;
238
             int emailCount = 0;
243
                     toList = toList.Substring(0, toList.Length - 2);
250
                     toList = toList.Substring(0, toList.Length - 2);
244
             }
251
             }
245
 
252
 
246
-            var host = _dbContext.Hosts.FirstOrDefault();
247
-            using (SmtpClient smtp = new SmtpClient(host.Host))
253
+            try
248
             {
254
             {
249
-                MailMessage mail = new MailMessage();
250
-                mail.To.Add(toList);
251
-                mail.Subject = "Uni-Vate - New Contact Request";
252
-                mail.Body = body;
253
-                mail.IsBodyHtml = true;
254
-                mail.BodyEncoding = Encoding.ASCII;
255
-                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
256
-                mail.Sender = new MailAddress(host.User, "UniVate Properties");
257
-                mail.From = mail.Sender;
255
+                var host = _dbContext.Hosts.FirstOrDefault();
256
+                using (SmtpClient smtp = new SmtpClient(host.Host))
257
+                {
258
+                    MailMessage mail = new MailMessage();
259
+                    mail.To.Add(toList);
260
+                    mail.Subject = "Uni-Vate - New Contact Request";
261
+                    mail.Body = body;
262
+                    mail.IsBodyHtml = true;
263
+                    mail.BodyEncoding = Encoding.ASCII;
264
+                    mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
265
+                    mail.Sender = new MailAddress(host.User, "UniVate Properties");
266
+                    mail.From = mail.Sender;
258
 
267
 
259
-                smtp.UseDefaultCredentials = host.NeedsAuthorize;
260
-                smtp.Credentials = host.GetNetworkCredential();
261
-                smtp.EnableSsl = host.UseSSL;
262
-                smtp.Send(mail);
268
+                    smtp.UseDefaultCredentials = host.NeedsAuthorize;
269
+                    smtp.Credentials = host.GetNetworkCredential();
270
+                    smtp.EnableSsl = host.UseSSL;
271
+                    smtp.Send(mail);
272
+                }
273
+            }
274
+            catch (Exception ex)
275
+            {
276
+                error = ex.ToString();
263
             }
277
             }
264
         }
278
         }
265
 
279
 
279
             body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
293
             body = body.Replace("[USERCELLPHONE]", bid.BidMaker.CellNumber);
280
             body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
294
             body = body.Replace("[USERTELEPHONE]", bid.BidMaker.Telephone);
281
             body = body.Replace("[USERCOMMENT]", bid.Comment);
295
             body = body.Replace("[USERCOMMENT]", bid.Comment);
296
+            body = body.Replace("[USERCONSENT]", bid.Consent.ToString());
282
 
297
 
283
-
284
-
285
-            var host = _dbContext.Hosts.FirstOrDefault();
286
-            using (SmtpClient smtp = new SmtpClient(host.Host))
298
+            try
287
             {
299
             {
288
-                MailMessage mail = new MailMessage();
289
-                mail.To.Add(bid.BidMaker.Email);
290
-                mail.Subject = "Uni-Vate - New Contact Request";
291
-                mail.Body = body;
292
-                mail.IsBodyHtml = true;
293
-                mail.BodyEncoding = Encoding.ASCII;
294
-                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
295
-                mail.Sender = new MailAddress(host.User, "UniVate Properties");
296
-                mail.From = mail.Sender;
300
+                var host = _dbContext.Hosts.FirstOrDefault();
301
+                using (SmtpClient smtp = new SmtpClient(host.Host))
302
+                {
303
+                    MailMessage mail = new MailMessage();
304
+                    mail.To.Add(bid.BidMaker.Email);
305
+                    mail.Subject = "Uni-Vate - New Contact Request";
306
+                    mail.Body = body;
307
+                    mail.IsBodyHtml = true;
308
+                    mail.BodyEncoding = Encoding.ASCII;
309
+                    mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
310
+                    mail.Sender = new MailAddress(host.User, "UniVate Properties");
311
+                    mail.From = mail.Sender;
297
 
312
 
298
-                smtp.UseDefaultCredentials = host.NeedsAuthorize;
299
-                smtp.Credentials = host.GetNetworkCredential();
300
-                smtp.EnableSsl = host.UseSSL;
301
-                smtp.Send(mail);
313
+                    smtp.UseDefaultCredentials = host.NeedsAuthorize;
314
+                    smtp.Credentials = host.GetNetworkCredential();
315
+                    smtp.EnableSsl = host.UseSSL;
316
+                    smtp.Send(mail);
317
+                }
318
+                error = "None";
319
+            }
320
+            catch (Exception ex)
321
+            {
322
+                error = ex.ToString();
302
             }
323
             }
303
         }
324
         }
304
 
325
 
508
 
529
 
509
         public List<MailModel> GetContactUsLog()
530
         public List<MailModel> GetContactUsLog()
510
         {
531
         {
511
-            return _dbContext.CommunicationLog.Where(x => x.ComType == "Contact Us").ToList();            
532
+            return _dbContext.CommunicationLog.Include("MailSource").Where(x => x.ComType == "Contact Us").ToList();
512
         }
533
         }
513
 
534
 
514
         public List<MailModel> GetEnquireNowLog()
535
         public List<MailModel> GetEnquireNowLog()

+ 96
- 0
UnivateProperties_API/Repository/Communication/MailSourceRepository.cs Wyświetl plik

1
+using Microsoft.EntityFrameworkCore;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Linq.Dynamic.Core;
6
+using UnivateProperties_API.Context;
7
+using UnivateProperties_API.Model.Communication;
8
+
9
+namespace UnivateProperties_API.Repository.Communication
10
+{
11
+    public class MailSourceRepository : IRepository<MailSource>
12
+    {
13
+        private readonly DataContext dBContext;
14
+
15
+        public MailSourceRepository(DataContext _dBContext)
16
+        {
17
+            dBContext = _dBContext;
18
+        }
19
+
20
+        public List<MailSource> Get(Func<MailSource, bool> where)
21
+        {
22
+            return dBContext.MailSources.Where(where).ToList();
23
+        }
24
+
25
+        public List<MailSource> GetAll()
26
+        {
27
+            return dBContext.MailSources.OrderBy(p => p.Description).ToList();
28
+        }
29
+
30
+        public MailSource GetDetailed(Func<MailSource, bool> first)
31
+        {
32
+            return dBContext.MailSources.FirstOrDefault(first);
33
+        }
34
+
35
+        public List<MailSource> GetDetailedAll()
36
+        {
37
+            return dBContext.MailSources.ToList();
38
+        }
39
+
40
+        public void Insert(MailSource item)
41
+        {
42
+            dBContext.MailSources.Add(item);
43
+            Save();
44
+        }
45
+
46
+        public void Insert(IEnumerable<MailSource> items)
47
+        {
48
+            foreach (var item in items)
49
+            {
50
+                dBContext.MailSources.Add(item);
51
+                Save();
52
+            }
53
+        }
54
+
55
+        public void Remove(MailSource item)
56
+        {
57
+            dBContext.MailSources.Remove(item);
58
+            Save();
59
+        }
60
+
61
+        public void Remove(IEnumerable<MailSource> items)
62
+        {
63
+            foreach (var item in items)
64
+            {
65
+                dBContext.MailSources.Remove(item);
66
+            }
67
+            Save();
68
+        }
69
+
70
+        public void RemoveAtId(int item)
71
+        {
72
+            var mailSource = Get(x => x.Id == item).FirstOrDefault();
73
+            if (mailSource != null)
74
+            {
75
+                dBContext.MailSources.Remove(mailSource);
76
+                Save();
77
+            }
78
+        }
79
+
80
+        public void Save()
81
+        {
82
+            dBContext.SaveChanges();
83
+        }
84
+
85
+        public void Update(MailSource item)
86
+        {
87
+            dBContext.Entry(item).State = EntityState.Modified;
88
+            Save();
89
+        }
90
+
91
+        public int NewId()
92
+        {
93
+            return 0;
94
+        }
95
+    }
96
+}

+ 1
- 1
UnivateProperties_API/Startup.cs Wyświetl plik

154
             services.AddTransient<IRepository<SMTPAccount>, SMTPAccountRepository>();
154
             services.AddTransient<IRepository<SMTPAccount>, SMTPAccountRepository>();
155
             services.AddTransient<IRepository<SMTPHost>, SMTPHostRepository>();
155
             services.AddTransient<IRepository<SMTPHost>, SMTPHostRepository>();
156
             services.AddTransient<IMailRepository, MailRepository>();
156
             services.AddTransient<IMailRepository, MailRepository>();
157
-
157
+            services.AddTransient<IRepository<MailSource>, MailSourceRepository>();
158
             #endregion Communication
158
             #endregion Communication
159
             #region Logs 
159
             #region Logs 
160
             services.AddTransient<ISearchLogRepository, SearchLogRepository>();
160
             services.AddTransient<ISearchLogRepository, SearchLogRepository>();

+ 1
- 0
UnivateProperties_API/appsettings.json Wyświetl plik

11
   "ConnectionStrings": {
11
   "ConnectionStrings": {
12
     "DefaultConnection": "Data Source=localhost;Initial Catalog=UniVate;Integrated Security=true;Pooling=false;",
12
     "DefaultConnection": "Data Source=localhost;Initial Catalog=UniVate;Integrated Security=true;Pooling=false;",
13
     //"DefaultConnection": "Data Source=localhost;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=sa;Password=What123!;Pooling=false;",
13
     //"DefaultConnection": "Data Source=localhost;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=sa;Password=What123!;Pooling=false;",
14
+    //"DefaultConnection": "Data Source=192.168.0.219;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=sa;Password=What123!;Pooling=false;",
14
     //"DefaultConnection": "Data Source=localhost;Initial Catalog=UniVate;Persist Security Info=True;User Id=Provision;Password=J%Xvk8xGeT;Pooling=false;",
15
     //"DefaultConnection": "Data Source=localhost;Initial Catalog=UniVate;Persist Security Info=True;User Id=Provision;Password=J%Xvk8xGeT;Pooling=false;",
15
     //"DefaultConnection": "Data Source=192.168.0.101;Initial Catalog=UniVate;Persist Security Info=True;User Id=Provision;Password=J%Xvk8xGeT;Pooling=false;",
16
     //"DefaultConnection": "Data Source=192.168.0.101;Initial Catalog=UniVate;Persist Security Info=True;User Id=Provision;Password=J%Xvk8xGeT;Pooling=false;",
16
     "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N",
17
     "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N",

Ładowanie…
Anuluj
Zapisz