George Williams пре 4 година
родитељ
комит
5ad8bf3530

+ 1
- 0
UnivateProperties_API/Containers/Users/UserDto.cs Прегледај датотеку

@@ -11,5 +11,6 @@
11 11
         public string Email { get; set; }
12 12
         public string Telephone { get; set; }
13 13
         public string CellNumber { get; set; }
14
+        public bool AcceptedTerms { get; set; }
14 15
     }
15 16
 }

+ 1
- 0
UnivateProperties_API/Context/DataContext.cs Прегледај датотеку

@@ -85,6 +85,7 @@ namespace UnivateProperties_API.Context
85 85
         public DbSet<Carousel> Carousel { get; set; }
86 86
         public DbSet<PlaceHolderFormat> PlaceHolderFormats { get; set; }
87 87
         public DbSet<Default> Defaults { get; set; }
88
+        public DbSet<TC> TermsConditions { get; set; }
88 89
         #endregion
89 90
 
90 91
         #region Payments

+ 3
- 3
UnivateProperties_API/Controllers/Financial/RedirectController.cs Прегледај датотеку

@@ -15,15 +15,15 @@ namespace UnivateProperties_API.Controllers.Financial
15 15
         {
16 16
             if (context.TRANSACTION_STATUS == 1)
17 17
             {
18
-                return Redirect("http://localhost:8080/#/payments/success");
18
+                return Redirect("http://training.provision-sa.com:122/#/payments/success");
19 19
             }
20 20
             else if (context.TRANSACTION_STATUS == 2)
21 21
             {
22
-                return Redirect("http://training.provision-sa.com:121/#/paymentError");
22
+                return Redirect("http://training.provision-sa.com:122/#/paymentError");
23 23
             }
24 24
             else
25 25
             {
26
-                return Redirect("http://localhost:8080/");
26
+                return Redirect("http://training.provision-sa.com:122/");
27 27
             }
28 28
 
29 29
         }

+ 39
- 0
UnivateProperties_API/Controllers/Misc/TCController.cs Прегледај датотеку

@@ -0,0 +1,39 @@
1
+using Microsoft.AspNetCore.Mvc;
2
+using UnivateProperties_API.Model.Misc;
3
+using UnivateProperties_API.Repository.Misc;
4
+
5
+namespace UnivateProperties_API.Controllers.Misc
6
+{
7
+    [Route("api/[controller]")]
8
+    [ApiController]
9
+    public class TCController : ControllerBase
10
+    {
11
+        private readonly ITCRepository _repo;
12
+
13
+        public TCController(ITCRepository rp)
14
+        {
15
+            _repo = rp;
16
+        }
17
+        // GET: api/TC/5
18
+        [HttpGet]
19
+        public IActionResult Get()
20
+        {
21
+            return new OkObjectResult(_repo.GetTC());
22
+        }
23
+
24
+        // POST: api/TC
25
+        [HttpPost]
26
+        public IActionResult Post([FromBody] TC terms)
27
+        {
28
+            if (terms != null)
29
+            {
30
+                _repo.SetTC(terms);
31
+                return Ok();
32
+            }
33
+            else
34
+            {
35
+                return new NoContentResult();
36
+            }
37
+        }
38
+    }
39
+}

+ 1621
- 0
UnivateProperties_API/Migrations/20200911083801_TC.Designer.cs
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 36
- 0
UnivateProperties_API/Migrations/20200911083801_TC.cs Прегледај датотеку

@@ -0,0 +1,36 @@
1
+using System;
2
+using Microsoft.EntityFrameworkCore.Metadata;
3
+using Microsoft.EntityFrameworkCore.Migrations;
4
+
5
+namespace UnivateProperties_API.Migrations
6
+{
7
+    public partial class TC : Migration
8
+    {
9
+        protected override void Up(MigrationBuilder migrationBuilder)
10
+        {
11
+            migrationBuilder.CreateTable(
12
+                name: "TermsConditions",
13
+                columns: table => new
14
+                {
15
+                    Id = table.Column<int>(nullable: false)
16
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
17
+                    Created = table.Column<DateTime>(nullable: false),
18
+                    Modified = table.Column<DateTime>(nullable: false),
19
+                    ModifiedBy = table.Column<string>(nullable: true),
20
+                    IsDeleted = table.Column<bool>(nullable: false),
21
+                    Version = table.Column<string>(nullable: true),
22
+                    TermsConditions = table.Column<string>(nullable: true)
23
+                },
24
+                constraints: table =>
25
+                {
26
+                    table.PrimaryKey("PK_TermsConditions", x => x.Id);
27
+                });
28
+        }
29
+
30
+        protected override void Down(MigrationBuilder migrationBuilder)
31
+        {
32
+            migrationBuilder.DropTable(
33
+                name: "TermsConditions");
34
+        }
35
+    }
36
+}

+ 1623
- 0
UnivateProperties_API/Migrations/20200911094328_UserTC.Designer.cs
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 23
- 0
UnivateProperties_API/Migrations/20200911094328_UserTC.cs Прегледај датотеку

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

+ 25
- 0
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs Прегледај датотеку

@@ -555,6 +555,29 @@ namespace UnivateProperties_API.Migrations
555 555
                     b.ToTable("PlaceHolderFormats");
556 556
                 });
557 557
 
558
+            modelBuilder.Entity("UnivateProperties_API.Model.Misc.TC", b =>
559
+                {
560
+                    b.Property<int>("Id")
561
+                        .ValueGeneratedOnAdd()
562
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
563
+
564
+                    b.Property<DateTime>("Created");
565
+
566
+                    b.Property<bool>("IsDeleted");
567
+
568
+                    b.Property<DateTime>("Modified");
569
+
570
+                    b.Property<string>("ModifiedBy");
571
+
572
+                    b.Property<string>("TermsConditions");
573
+
574
+                    b.Property<string>("Version");
575
+
576
+                    b.HasKey("Id");
577
+
578
+                    b.ToTable("TermsConditions");
579
+                });
580
+
558 581
             modelBuilder.Entity("UnivateProperties_API.Model.ProcessFlow.BidItem", b =>
559 582
                 {
560 583
                     b.Property<int>("Id")
@@ -1293,6 +1316,8 @@ namespace UnivateProperties_API.Migrations
1293 1316
                         .ValueGeneratedOnAdd()
1294 1317
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
1295 1318
 
1319
+                    b.Property<bool>("AcceptedTerms");
1320
+
1296 1321
                     b.Property<DateTime>("Created");
1297 1322
 
1298 1323
                     b.Property<bool>("IsDeleted");

+ 13
- 0
UnivateProperties_API/Model/Misc/TC.cs Прегледај датотеку

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace UnivateProperties_API.Model.Misc
7
+{
8
+    public class TC : BaseEntity
9
+    {
10
+        public string Version { get; set; }
11
+        public string TermsConditions { get; set; }
12
+    }
13
+}

+ 1
- 0
UnivateProperties_API/Model/Users/User.cs Прегледај датотеку

@@ -31,6 +31,7 @@ namespace UnivateProperties_API.Model.Users
31 31
         public byte[] PasswordSalt { get; set; }
32 32
         public bool Verified { get; set; }
33 33
         public string Token { get; set; }
34
+        public bool AcceptedTerms { get; set; }
34 35
         #endregion Properties
35 36
 
36 37
         #region Methods

+ 19
- 3
UnivateProperties_API/Repository/Communication/MailRepository.cs Прегледај датотеку

@@ -1,5 +1,9 @@
1 1
 using MailKit.Net.Smtp;
2 2
 using MimeKit;
3
+using System;
4
+using System.Linq;
5
+using System.Linq.Dynamic.Core;
6
+using UnivateProperties_API.Context;
3 7
 using UnivateProperties_API.Model.Communication;
4 8
 
5 9
 namespace UnivateProperties_API.Repository.Communication
@@ -12,6 +16,13 @@ namespace UnivateProperties_API.Repository.Communication
12 16
 
13 17
     public class MailRepository : IMailRepository
14 18
     {
19
+        private readonly DataContext _dbContext;
20
+
21
+        public MailRepository(DataContext db)
22
+        {
23
+            _dbContext = db;
24
+        }
25
+
15 26
         MimeMessage messageObj = new MimeMessage();
16 27
         MailboxAddress from;
17 28
         MailboxAddress to;
@@ -63,7 +74,9 @@ namespace UnivateProperties_API.Repository.Communication
63 74
             string name = mm.Name;
64 75
             string email = mm.Email;
65 76
             string message = mm.Message;
66
-
77
+            var props = _dbContext.Properties.ToList();
78
+            var prop = props.Where(x => x.Id == Convert.ToInt32(mm.Property)).FirstOrDefault();
79
+            
67 80
             from = new MailboxAddress("Admin", mm.FromAddress);
68 81
 
69 82
             to = new MailboxAddress("User", mm.ToAddress);
@@ -78,8 +91,11 @@ namespace UnivateProperties_API.Repository.Communication
78 91
                 "<h4>Email: " + email + "</h4>" +
79 92
                 "<h4>Phone: " + phone + "</h4>" +
80 93
                 "<div>" +
81
-                "<h4>Message: </h4>" +
82
-                "<p>" + message + "</p>" +
94
+                "<h4>Property: </h4>" +
95
+                "<p>" + prop.Id + "</p>" +
96
+                "<p>" + prop.PropertyName + "</p>" +
97
+                "<p>" + prop.PropertyRef + "</p>" +
98
+                "<p>" + prop.Price + "</p>" +
83 99
                 "</div>" +
84 100
                 "</div>" +
85 101
                 "</div>";

+ 53
- 0
UnivateProperties_API/Repository/Misc/TCRepository.cs Прегледај датотеку

@@ -0,0 +1,53 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using UnivateProperties_API.Context;
6
+using UnivateProperties_API.Model.Misc;
7
+
8
+namespace UnivateProperties_API.Repository.Misc
9
+{
10
+    public interface ITCRepository
11
+    {
12
+        void SetTC(TC terms);
13
+        TC GetTC();
14
+    }
15
+
16
+    public class TCRepository : ITCRepository
17
+    {
18
+        private readonly DataContext _dbContext;
19
+
20
+        public TCRepository(DataContext db)
21
+        {
22
+            _dbContext = db;
23
+        }
24
+
25
+        public void SetTC(TC terms)
26
+        {
27
+            var pulledTerms = _dbContext.TermsConditions.FirstOrDefault();
28
+            if (terms != null)
29
+            {
30
+                if (pulledTerms == null)
31
+                {
32
+                    _dbContext.TermsConditions.Add(terms);
33
+                    _dbContext.SaveChanges();
34
+                }
35
+                else
36
+                {
37
+                    pulledTerms.TermsConditions = terms.TermsConditions;
38
+                    pulledTerms.Version = terms.Version;
39
+
40
+                    _dbContext.TermsConditions.Update(pulledTerms);
41
+                    _dbContext.SaveChanges();
42
+                }
43
+                
44
+            }
45
+            
46
+        }
47
+
48
+        public TC GetTC()
49
+        {
50
+            return _dbContext.TermsConditions.FirstOrDefault();
51
+        }
52
+    }
53
+}

+ 1
- 1
UnivateProperties_API/Repository/Users/IRegisterRepository.cs Прегледај датотеку

@@ -8,7 +8,7 @@ namespace UnivateProperties_API.Repository.Users
8 8
     public interface IRegisterRepository
9 9
     {
10 10
         User Authenticate(string username, string password);
11
-        User Create(User user, string password, bool save);
11
+        User Create(User user, string password, bool save, bool terms);
12 12
         Agency CreateAgency(AgencyDto agency);
13 13
         void CreatePerson(UserDto individual, PersonType personType, bool save, Agency agency);
14 14
         void Update(User userParam, string password = null);

+ 3
- 2
UnivateProperties_API/Repository/Users/RegisterRepository.cs Прегледај датотеку

@@ -39,7 +39,7 @@ namespace UnivateProperties_API.Repository.Users
39 39
             return user;
40 40
         }
41 41
 
42
-        public User Create(User user, string password, bool save)
42
+        public User Create(User user, string password, bool save, bool terms)
43 43
         {
44 44
             // validation
45 45
             if (string.IsNullOrWhiteSpace(password))
@@ -52,6 +52,7 @@ namespace UnivateProperties_API.Repository.Users
52 52
 
53 53
             user.PasswordHash = passwordHash;
54 54
             user.PasswordSalt = passwordSalt;
55
+            user.AcceptedTerms = terms;
55 56
             //user.Id = NewUserId();
56 57
             _dbContext.Users.Add(user);
57 58
             if (save)
@@ -99,7 +100,7 @@ namespace UnivateProperties_API.Repository.Users
99 100
 
100 101
             User createUser = new User(individual.Username, individual.Password);
101 102
 
102
-            Create(createUser, individual.Password, false);
103
+            Create(createUser, individual.Password, false, individual.AcceptedTerms);
103 104
 
104 105
             Person p = null;
105 106
             

+ 2
- 1
UnivateProperties_API/Startup.cs Прегледај датотеку

@@ -162,7 +162,8 @@ namespace UnivateProperties_API
162 162
             #endregion
163 163
             #region Misc
164 164
             services.AddTransient<ICarouselRepository, CarouselRepository>();
165
-            services.AddTransient<IRepository<PlaceHolderFormat>, PlaceHolderFormatRepository>();            
165
+            services.AddTransient<IRepository<PlaceHolderFormat>, PlaceHolderFormatRepository>();
166
+            services.AddTransient<ITCRepository, TCRepository>();
166 167
             #endregion
167 168
             #region Campaign 
168 169
             services.AddTransient<ICampaignRepository, CampaignRepository>();

Loading…
Откажи
Сачувај