George Williams 4 lat temu
rodzic
commit
5ad8bf3530

+ 1
- 0
UnivateProperties_API/Containers/Users/UserDto.cs Wyświetl plik

11
         public string Email { get; set; }
11
         public string Email { get; set; }
12
         public string Telephone { get; set; }
12
         public string Telephone { get; set; }
13
         public string CellNumber { get; set; }
13
         public string CellNumber { get; set; }
14
+        public bool AcceptedTerms { get; set; }
14
     }
15
     }
15
 }
16
 }

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

85
         public DbSet<Carousel> Carousel { get; set; }
85
         public DbSet<Carousel> Carousel { get; set; }
86
         public DbSet<PlaceHolderFormat> PlaceHolderFormats { get; set; }
86
         public DbSet<PlaceHolderFormat> PlaceHolderFormats { get; set; }
87
         public DbSet<Default> Defaults { get; set; }
87
         public DbSet<Default> Defaults { get; set; }
88
+        public DbSet<TC> TermsConditions { get; set; }
88
         #endregion
89
         #endregion
89
 
90
 
90
         #region Payments
91
         #region Payments

+ 3
- 3
UnivateProperties_API/Controllers/Financial/RedirectController.cs Wyświetl plik

15
         {
15
         {
16
             if (context.TRANSACTION_STATUS == 1)
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
             else if (context.TRANSACTION_STATUS == 2)
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
             else
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 Wyświetl plik

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
Plik diff jest za duży
Wyświetl plik


+ 36
- 0
UnivateProperties_API/Migrations/20200911083801_TC.cs Wyświetl plik

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
Plik diff jest za duży
Wyświetl plik


+ 23
- 0
UnivateProperties_API/Migrations/20200911094328_UserTC.cs Wyświetl plik

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 Wyświetl plik

555
                     b.ToTable("PlaceHolderFormats");
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
             modelBuilder.Entity("UnivateProperties_API.Model.ProcessFlow.BidItem", b =>
581
             modelBuilder.Entity("UnivateProperties_API.Model.ProcessFlow.BidItem", b =>
559
                 {
582
                 {
560
                     b.Property<int>("Id")
583
                     b.Property<int>("Id")
1293
                         .ValueGeneratedOnAdd()
1316
                         .ValueGeneratedOnAdd()
1294
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
1317
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
1295
 
1318
 
1319
+                    b.Property<bool>("AcceptedTerms");
1320
+
1296
                     b.Property<DateTime>("Created");
1321
                     b.Property<DateTime>("Created");
1297
 
1322
 
1298
                     b.Property<bool>("IsDeleted");
1323
                     b.Property<bool>("IsDeleted");

+ 13
- 0
UnivateProperties_API/Model/Misc/TC.cs Wyświetl plik

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 Wyświetl plik

31
         public byte[] PasswordSalt { get; set; }
31
         public byte[] PasswordSalt { get; set; }
32
         public bool Verified { get; set; }
32
         public bool Verified { get; set; }
33
         public string Token { get; set; }
33
         public string Token { get; set; }
34
+        public bool AcceptedTerms { get; set; }
34
         #endregion Properties
35
         #endregion Properties
35
 
36
 
36
         #region Methods
37
         #region Methods

+ 19
- 3
UnivateProperties_API/Repository/Communication/MailRepository.cs Wyświetl plik

1
 using MailKit.Net.Smtp;
1
 using MailKit.Net.Smtp;
2
 using MimeKit;
2
 using MimeKit;
3
+using System;
4
+using System.Linq;
5
+using System.Linq.Dynamic.Core;
6
+using UnivateProperties_API.Context;
3
 using UnivateProperties_API.Model.Communication;
7
 using UnivateProperties_API.Model.Communication;
4
 
8
 
5
 namespace UnivateProperties_API.Repository.Communication
9
 namespace UnivateProperties_API.Repository.Communication
12
 
16
 
13
     public class MailRepository : IMailRepository
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
         MimeMessage messageObj = new MimeMessage();
26
         MimeMessage messageObj = new MimeMessage();
16
         MailboxAddress from;
27
         MailboxAddress from;
17
         MailboxAddress to;
28
         MailboxAddress to;
63
             string name = mm.Name;
74
             string name = mm.Name;
64
             string email = mm.Email;
75
             string email = mm.Email;
65
             string message = mm.Message;
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
             from = new MailboxAddress("Admin", mm.FromAddress);
80
             from = new MailboxAddress("Admin", mm.FromAddress);
68
 
81
 
69
             to = new MailboxAddress("User", mm.ToAddress);
82
             to = new MailboxAddress("User", mm.ToAddress);
78
                 "<h4>Email: " + email + "</h4>" +
91
                 "<h4>Email: " + email + "</h4>" +
79
                 "<h4>Phone: " + phone + "</h4>" +
92
                 "<h4>Phone: " + phone + "</h4>" +
80
                 "<div>" +
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
                 "</div>" +
99
                 "</div>" +
84
                 "</div>" +
100
                 "</div>" +
85
                 "</div>";
101
                 "</div>";

+ 53
- 0
UnivateProperties_API/Repository/Misc/TCRepository.cs Wyświetl plik

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 Wyświetl plik

8
     public interface IRegisterRepository
8
     public interface IRegisterRepository
9
     {
9
     {
10
         User Authenticate(string username, string password);
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
         Agency CreateAgency(AgencyDto agency);
12
         Agency CreateAgency(AgencyDto agency);
13
         void CreatePerson(UserDto individual, PersonType personType, bool save, Agency agency);
13
         void CreatePerson(UserDto individual, PersonType personType, bool save, Agency agency);
14
         void Update(User userParam, string password = null);
14
         void Update(User userParam, string password = null);

+ 3
- 2
UnivateProperties_API/Repository/Users/RegisterRepository.cs Wyświetl plik

39
             return user;
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
             // validation
44
             // validation
45
             if (string.IsNullOrWhiteSpace(password))
45
             if (string.IsNullOrWhiteSpace(password))
52
 
52
 
53
             user.PasswordHash = passwordHash;
53
             user.PasswordHash = passwordHash;
54
             user.PasswordSalt = passwordSalt;
54
             user.PasswordSalt = passwordSalt;
55
+            user.AcceptedTerms = terms;
55
             //user.Id = NewUserId();
56
             //user.Id = NewUserId();
56
             _dbContext.Users.Add(user);
57
             _dbContext.Users.Add(user);
57
             if (save)
58
             if (save)
99
 
100
 
100
             User createUser = new User(individual.Username, individual.Password);
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
             Person p = null;
105
             Person p = null;
105
             
106
             

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

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

Ładowanie…
Anuluj
Zapisz