Browse Source

Property Publish & payments

Property Flow (WIP)
master
George Williams 5 years ago
parent
commit
ed55e65449

+ 2
- 1
UnivateProperties_API/Containers/Property/PropertyList.cs View File

9
         public int Id { get; set; }
9
         public int Id { get; set; }
10
         public DateTime DateAvailable { get; set; }
10
         public DateTime DateAvailable { get; set; }
11
         public string Size { get; set; }
11
         public string Size { get; set; }
12
-        public string Price { get; set; }
12
+        public decimal Price { get; set; }
13
         public string UsageType { get; set;  }
13
         public string UsageType { get; set;  }
14
         public string Type { get; set; }
14
         public string Type { get; set; }
15
         public string SaleType { get; set; }
15
         public string SaleType { get; set; }
16
         public string Publish { get; set; }
16
         public string Publish { get; set; }
17
         public string Status { get; set; }
17
         public string Status { get; set; }
18
         public string CarouselDescription { get; set; }
18
         public string CarouselDescription { get; set; }
19
+        public bool IsPublished { get; set; }
19
         #endregion
20
         #endregion
20
     }
21
     }
21
 }
22
 }

+ 12
- 9
UnivateProperties_API/Context/DataContext.cs View File

1
 using Microsoft.EntityFrameworkCore;
1
 using Microsoft.EntityFrameworkCore;
2
-
3
-using UnivateProperties_API.Model.Communication;
4
-using UnivateProperties_API.Model.Users;
5
-using UnivateProperties_API.Model.Properties;
6
-using UnivateProperties_API.Model.Region;
7
-using UnivateProperties_API.Model.Timeshare;
2
+using Npgsql;
8
 using System.Linq;
3
 using System.Linq;
9
 using UnivateProperties_API.Model;
4
 using UnivateProperties_API.Model;
10
 using UnivateProperties_API.Model.Banks;
5
 using UnivateProperties_API.Model.Banks;
6
+using UnivateProperties_API.Model.Communication;
7
+using UnivateProperties_API.Model.Financial;
8
+using UnivateProperties_API.Model.Logging;
11
 using UnivateProperties_API.Model.Misc;
9
 using UnivateProperties_API.Model.Misc;
12
 using UnivateProperties_API.Model.ProcessFlow;
10
 using UnivateProperties_API.Model.ProcessFlow;
13
-using UnivateProperties_API.Model.Logging;
14
-using Npgsql;
15
-using System;
11
+using UnivateProperties_API.Model.Properties;
12
+using UnivateProperties_API.Model.Region;
13
+using UnivateProperties_API.Model.Timeshare;
14
+using UnivateProperties_API.Model.Users;
16
 
15
 
17
 namespace UnivateProperties_API.Context
16
 namespace UnivateProperties_API.Context
18
 {
17
 {
85
         public DbSet<Carousel> Carousel { get; set; }
84
         public DbSet<Carousel> Carousel { get; set; }
86
         #endregion
85
         #endregion
87
 
86
 
87
+        #region Payments
88
+        public DbSet<Payment> Payments { get; set; }
89
+        #endregion
90
+
88
         public override int SaveChanges()
91
         public override int SaveChanges()
89
         {
92
         {
90
             foreach (var item in ChangeTracker
93
             foreach (var item in ChangeTracker

+ 57
- 0
UnivateProperties_API/Controllers/Financial/PaymentController.cs View File

1
+using Microsoft.AspNetCore.Mvc;
2
+using System.Transactions;
3
+using UnivateProperties_API.Model.Financial;
4
+using UnivateProperties_API.Repository;
5
+
6
+namespace UnivateProperties_API.Controllers.Financial
7
+{
8
+    [Route("api/[controller]")]
9
+    [ApiController]
10
+    public class PaymentController : ControllerBase
11
+    {
12
+        private readonly IRepository<Payment> _Repo;
13
+
14
+        public PaymentController(IRepository<Payment> _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.Get(x => x.Id == id));
29
+        }
30
+        
31
+        [HttpPost]
32
+        public IActionResult Post([FromBody] Payment payment)
33
+        {
34
+            using (var scope = new TransactionScope())
35
+            {
36
+                _Repo.Insert(payment);
37
+                scope.Complete();
38
+                return CreatedAtAction(nameof(Get), new { id = payment.Id }, payment);
39
+            }
40
+        }
41
+        
42
+        [HttpPut("{id}")]
43
+        public IActionResult Put([FromBody] Payment payment)
44
+        {
45
+            if (payment != null)
46
+            {
47
+                using (var scope = new TransactionScope())
48
+                {
49
+                    _Repo.Update(payment);
50
+                    scope.Complete();
51
+                    return new OkResult();
52
+                }
53
+            }
54
+            return new NoContentResult();
55
+        }       
56
+    }
57
+}

+ 21
- 1
UnivateProperties_API/Controllers/Properties/PropertyController.cs View File

51
             return new OkObjectResult(_Repo.GetPropertyList(by));
51
             return new OkObjectResult(_Repo.GetPropertyList(by));
52
         }
52
         }
53
 
53
 
54
+        [HttpGet("GetLivePropertyList")]
55
+        public IActionResult GetLivePropertyList()
56
+        {
57
+            return new OkObjectResult(_Repo.GetPropertyList());
58
+        }
59
+
54
         [HttpGet("MayEditProperty/{id}")]
60
         [HttpGet("MayEditProperty/{id}")]
55
         public IActionResult MayEditProperty(int id)
61
         public IActionResult MayEditProperty(int id)
56
         {
62
         {
116
                 }
122
                 }
117
             }
123
             }
118
             return new NoContentResult();
124
             return new NoContentResult();
119
-        }        
125
+        }
126
+        
127
+        [HttpPut("PublishProperty")]
128
+        public IActionResult PublishProperty([FromBody] PropertyDisplay property)
129
+        {
130
+            _Repo.PublishProperty(property.Id);
131
+            return new NoContentResult();
132
+        }
133
+
134
+        [HttpPut("UnpublishProperty")]
135
+        public IActionResult UnpublishProperty(PropertyDisplay property)
136
+        {
137
+            _Repo.UnpublishProperty(property.Id);
138
+            return new NoContentResult();
139
+        }
120
 
140
 
121
         [HttpDelete("{id}")]
141
         [HttpDelete("{id}")]
122
         public IActionResult Delete(int id)
142
         public IActionResult Delete(int id)

+ 1339
- 0
UnivateProperties_API/Migrations/20200121103350_PaymentsTable.Designer.cs
File diff suppressed because it is too large
View File


+ 60
- 0
UnivateProperties_API/Migrations/20200121103350_PaymentsTable.cs View File

1
+using System;
2
+using Microsoft.EntityFrameworkCore.Migrations;
3
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4
+
5
+namespace UnivateProperties_API.Migrations
6
+{
7
+    public partial class PaymentsTable : Migration
8
+    {
9
+        protected override void Up(MigrationBuilder migrationBuilder)
10
+        {
11
+            migrationBuilder.CreateTable(
12
+                name: "Payments",
13
+                columns: table => new
14
+                {
15
+                    Id = table.Column<int>(nullable: false)
16
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
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
+                    TimeshareWeekId = table.Column<int>(nullable: true),
22
+                    PropertyId = table.Column<int>(nullable: true),
23
+                    Amount = table.Column<decimal>(nullable: false),
24
+                    PaymentStatus = table.Column<string>(nullable: true)
25
+                },
26
+                constraints: table =>
27
+                {
28
+                    table.PrimaryKey("PK_Payments", x => x.Id);
29
+                    table.ForeignKey(
30
+                        name: "FK_Payments_Properties_PropertyId",
31
+                        column: x => x.PropertyId,
32
+                        principalTable: "Properties",
33
+                        principalColumn: "Id",
34
+                        onDelete: ReferentialAction.Restrict);
35
+                    table.ForeignKey(
36
+                        name: "FK_Payments_Weeks_TimeshareWeekId",
37
+                        column: x => x.TimeshareWeekId,
38
+                        principalTable: "Weeks",
39
+                        principalColumn: "Id",
40
+                        onDelete: ReferentialAction.Restrict);
41
+                });
42
+
43
+            migrationBuilder.CreateIndex(
44
+                name: "IX_Payments_PropertyId",
45
+                table: "Payments",
46
+                column: "PropertyId");
47
+
48
+            migrationBuilder.CreateIndex(
49
+                name: "IX_Payments_TimeshareWeekId",
50
+                table: "Payments",
51
+                column: "TimeshareWeekId");
52
+        }
53
+
54
+        protected override void Down(MigrationBuilder migrationBuilder)
55
+        {
56
+            migrationBuilder.DropTable(
57
+                name: "Payments");
58
+        }
59
+    }
60
+}

+ 1350
- 0
UnivateProperties_API/Migrations/20200122063527_ExtraPaymentFields.Designer.cs
File diff suppressed because it is too large
View File


+ 53
- 0
UnivateProperties_API/Migrations/20200122063527_ExtraPaymentFields.cs View File

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class ExtraPaymentFields : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<int>(
10
+                name: "CreatedById",
11
+                table: "Payments",
12
+                nullable: false,
13
+                defaultValue: 0);
14
+
15
+            migrationBuilder.AddColumn<string>(
16
+                name: "PaymentToken",
17
+                table: "Payments",
18
+                nullable: true);
19
+
20
+            migrationBuilder.CreateIndex(
21
+                name: "IX_Payments_CreatedById",
22
+                table: "Payments",
23
+                column: "CreatedById");
24
+
25
+            migrationBuilder.AddForeignKey(
26
+                name: "FK_Payments_Users_CreatedById",
27
+                table: "Payments",
28
+                column: "CreatedById",
29
+                principalTable: "Users",
30
+                principalColumn: "Id",
31
+                onDelete: ReferentialAction.Cascade);
32
+        }
33
+
34
+        protected override void Down(MigrationBuilder migrationBuilder)
35
+        {
36
+            migrationBuilder.DropForeignKey(
37
+                name: "FK_Payments_Users_CreatedById",
38
+                table: "Payments");
39
+
40
+            migrationBuilder.DropIndex(
41
+                name: "IX_Payments_CreatedById",
42
+                table: "Payments");
43
+
44
+            migrationBuilder.DropColumn(
45
+                name: "CreatedById",
46
+                table: "Payments");
47
+
48
+            migrationBuilder.DropColumn(
49
+                name: "PaymentToken",
50
+                table: "Payments");
51
+        }
52
+    }
53
+}

+ 1352
- 0
UnivateProperties_API/Migrations/20200122131033_DatePublishedToPorp.Designer.cs
File diff suppressed because it is too large
View File


+ 24
- 0
UnivateProperties_API/Migrations/20200122131033_DatePublishedToPorp.cs View File

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

+ 54
- 0
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs View File

223
                     b.ToTable("Templates");
223
                     b.ToTable("Templates");
224
                 });
224
                 });
225
 
225
 
226
+            modelBuilder.Entity("UnivateProperties_API.Model.Financial.Payment", b =>
227
+                {
228
+                    b.Property<int>("Id")
229
+                        .ValueGeneratedOnAdd();
230
+
231
+                    b.Property<decimal>("Amount");
232
+
233
+                    b.Property<DateTime>("Created");
234
+
235
+                    b.Property<int>("CreatedById");
236
+
237
+                    b.Property<bool>("IsDeleted");
238
+
239
+                    b.Property<DateTime>("Modified");
240
+
241
+                    b.Property<string>("ModifiedBy");
242
+
243
+                    b.Property<string>("PaymentStatus");
244
+
245
+                    b.Property<string>("PaymentToken");
246
+
247
+                    b.Property<int?>("PropertyId");
248
+
249
+                    b.Property<int?>("TimeshareWeekId");
250
+
251
+                    b.HasKey("Id");
252
+
253
+                    b.HasIndex("CreatedById");
254
+
255
+                    b.HasIndex("PropertyId");
256
+
257
+                    b.HasIndex("TimeshareWeekId");
258
+
259
+                    b.ToTable("Payments");
260
+                });
261
+
226
             modelBuilder.Entity("UnivateProperties_API.Model.Logging.SearchLog", b =>
262
             modelBuilder.Entity("UnivateProperties_API.Model.Logging.SearchLog", b =>
227
                 {
263
                 {
228
                     b.Property<int>("Id")
264
                     b.Property<int>("Id")
418
 
454
 
419
                     b.Property<DateTime>("DateAvailable");
455
                     b.Property<DateTime>("DateAvailable");
420
 
456
 
457
+                    b.Property<DateTime>("DatePublished");
458
+
421
                     b.Property<string>("Description");
459
                     b.Property<string>("Description");
422
 
460
 
423
                     b.Property<bool>("IsDeleted");
461
                     b.Property<bool>("IsDeleted");
1090
                         .HasForeignKey("SenderId");
1128
                         .HasForeignKey("SenderId");
1091
                 });
1129
                 });
1092
 
1130
 
1131
+            modelBuilder.Entity("UnivateProperties_API.Model.Financial.Payment", b =>
1132
+                {
1133
+                    b.HasOne("UnivateProperties_API.Model.Users.User", "CreatedBy")
1134
+                        .WithMany()
1135
+                        .HasForeignKey("CreatedById")
1136
+                        .OnDelete(DeleteBehavior.Cascade);
1137
+
1138
+                    b.HasOne("UnivateProperties_API.Model.Properties.Property", "Property")
1139
+                        .WithMany()
1140
+                        .HasForeignKey("PropertyId");
1141
+
1142
+                    b.HasOne("UnivateProperties_API.Model.Timeshare.TimeshareWeek", "TimeshareWeek")
1143
+                        .WithMany()
1144
+                        .HasForeignKey("TimeshareWeekId");
1145
+                });
1146
+
1093
             modelBuilder.Entity("UnivateProperties_API.Model.Misc.Address", b =>
1147
             modelBuilder.Entity("UnivateProperties_API.Model.Misc.Address", b =>
1094
                 {
1148
                 {
1095
                     b.HasOne("UnivateProperties_API.Model.Users.Individual", "Owner")
1149
                     b.HasOne("UnivateProperties_API.Model.Users.Individual", "Owner")

+ 27
- 0
UnivateProperties_API/Model/Financial/Payment.cs View File

1
+using System.ComponentModel.DataAnnotations.Schema;
2
+using UnivateProperties_API.Model.Properties;
3
+using UnivateProperties_API.Model.Timeshare;
4
+using UnivateProperties_API.Model.Users;
5
+
6
+namespace UnivateProperties_API.Model.Financial
7
+{
8
+    public class Payment : BaseEntity
9
+    {
10
+        #region Properties
11
+        [ForeignKey("TimeshareWeek")]
12
+        public int? TimeshareWeekId { get; set; }
13
+        [ForeignKey("Property")]
14
+        public int? PropertyId { get; set; }
15
+        [ForeignKey("CreatedBy")]
16
+        public int CreatedById { get; set; }
17
+        public decimal Amount { get; set; }
18
+        public string PaymentStatus { get; set; }
19
+        public string PaymentToken { get; set; }
20
+
21
+
22
+        public virtual TimeshareWeek TimeshareWeek { get; set; }
23
+        public virtual Property Property { get; set; }
24
+        public virtual User CreatedBy { get; set; }
25
+        #endregion
26
+    }
27
+}

+ 1
- 0
UnivateProperties_API/Model/Properties/Property.cs View File

29
         public int CityId { get; set; }
29
         public int CityId { get; set; }
30
         public int ProvinceId { get; set; }
30
         public int ProvinceId { get; set; }
31
         public bool Published { get; set; }
31
         public bool Published { get; set; }
32
+        public DateTime DatePublished { get; set; }
32
         public string VirtualTour { get; set; }
33
         public string VirtualTour { get; set; }
33
         public string Video { get; set; }
34
         public string Video { get; set; }
34
         [ForeignKey("Status")]
35
         [ForeignKey("Status")]

+ 95
- 0
UnivateProperties_API/Repository/Financial/PaymentRepository.cs View File

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

+ 1
- 0
UnivateProperties_API/Repository/Misc/CarouselRepository.cs View File

59
         {
59
         {
60
             string image = item.Image;
60
             string image = item.Image;
61
             item.Image = "";
61
             item.Image = "";
62
+            item.Id = dBContext.GetMaxID("Carousel") + 1;
62
             dBContext.Add(item);
63
             dBContext.Add(item);
63
             Save();
64
             Save();
64
 
65
 

+ 3
- 0
UnivateProperties_API/Repository/Properties/IPropertyRepository.cs View File

13
         List<PropertyDisplay> GetLatestDisplay();
13
         List<PropertyDisplay> GetLatestDisplay();
14
         List<PropertyType> GetPropertyTypes(Func<PropertyType, bool> where);
14
         List<PropertyType> GetPropertyTypes(Func<PropertyType, bool> where);
15
         List<PropertyList> GetPropertyList(int By);
15
         List<PropertyList> GetPropertyList(int By);
16
+        List<PropertyList> GetPropertyList();
16
         void Insert(PropertyContainer items);
17
         void Insert(PropertyContainer items);
17
         PropertyContainer GetDetailed(int id, bool detailed);
18
         PropertyContainer GetDetailed(int id, bool detailed);
18
         void Update(PropertyContainer item);
19
         void Update(PropertyContainer item);
19
         bool MayEdit(int id);
20
         bool MayEdit(int id);
20
         void InsertImages(int propertyID, List<PropertyImage> Images);
21
         void InsertImages(int propertyID, List<PropertyImage> Images);
21
         void InsertFields(int propertyID, List<PropertyUserField> Fields);
22
         void InsertFields(int propertyID, List<PropertyUserField> Fields);
23
+        void PublishProperty(int propertyID);
24
+        void UnpublishProperty(int propertyID);
22
     }
25
     }
23
 }
26
 }

+ 43
- 8
UnivateProperties_API/Repository/Properties/PropertyRepository.cs View File

497
                 Type = item.Type,
497
                 Type = item.Type,
498
                 Search = JsonConvert.SerializeObject(item)
498
                 Search = JsonConvert.SerializeObject(item)
499
             };
499
             };
500
+            searchLog.Id = dBContext.GetMaxID("SearchLogs") + 1;
500
             dBContext.SearchLogs.Add(searchLog);
501
             dBContext.SearchLogs.Add(searchLog);
501
             Save();
502
             Save();
502
         }
503
         }
504
         private List<PropertyDisplay> GetDisplayDetails(List<Property> props)
505
         private List<PropertyDisplay> GetDisplayDetails(List<Property> props)
505
         {
506
         {
506
             var properties = new List<PropertyDisplay>();
507
             var properties = new List<PropertyDisplay>();
508
+            props = props.Where(p => p.Published).ToList();
507
             foreach (var item in props)
509
             foreach (var item in props)
508
             {                
510
             {                
509
                 PropertyDisplay display = new PropertyDisplay
511
                 PropertyDisplay display = new PropertyDisplay
589
 
591
 
590
         public List<PropertyDisplay> GetLatestDisplay()
592
         public List<PropertyDisplay> GetLatestDisplay()
591
         {
593
         {
592
-            List<Property> props = GetAll().OrderByDescending(x => x.Created).Take(3).ToList();
594
+            List<Property> props = GetAll().Where(x => x.Published).OrderByDescending(x => x.DatePublished).Take(3).ToList();
593
             return GetDisplayDetails(props);
595
             return GetDisplayDetails(props);
594
         }
596
         }
595
 
597
 
619
                 }
621
                 }
620
                 if (user.Role.ToUpper() == "SUPER ADMIN")
622
                 if (user.Role.ToUpper() == "SUPER ADMIN")
621
                     properties = dBContext.Properties.Include("City").Include("Suburb").ToList();
623
                     properties = dBContext.Properties.Include("City").Include("Suburb").ToList();
622
-            }           
623
-            
624
+            }
625
+
626
+            return SetPropertyList(properties);
627
+        }
628
+
629
+        public List<PropertyList> GetPropertyList()
630
+        {
631
+            return SetPropertyList(dBContext.Properties.Where(x => x.Published).ToList());
632
+        }
633
+
634
+        private List<PropertyList> SetPropertyList(List<Property> properties)
635
+        {
624
             List<PropertyList> list = new List<PropertyList>();
636
             List<PropertyList> list = new List<PropertyList>();
625
 
637
 
626
             foreach (Property p in properties)
638
             foreach (Property p in properties)
629
                 {
641
                 {
630
                     Id = p.Id,
642
                     Id = p.Id,
631
                     Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName,
643
                     Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName,
632
-                    Price = string.Format("R {0:n}", p.Price),
633
-                    Publish = p.Published.ToString(),
644
+                    Price = p.Price,
645
+                    Publish = p.Published ? "Yes" : "No",
634
                     Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description,
646
                     Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description,
635
-                    CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb.Description, p.City.Description, p.AddressLine3),
636
-                    DateAvailable = p.DateAvailable
647
+                    CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb?.Description, p.City?.Description, p.AddressLine3),
648
+                    DateAvailable = p.IsSale ? DateTime.MinValue : p.DateAvailable,
649
+                    IsPublished = p.Published
637
                 };
650
                 };
638
 
651
 
639
                 prop.Size = (from u in dBContext.PropertyUserFields
652
                 prop.Size = (from u in dBContext.PropertyUserFields
652
 
665
 
653
                 list.Add(prop);
666
                 list.Add(prop);
654
             }
667
             }
655
-                
668
+
656
             return list;
669
             return list;
657
         }
670
         }
658
 
671
 
816
         {
829
         {
817
             throw new NotImplementedException();
830
             throw new NotImplementedException();
818
         }
831
         }
832
+
833
+        public void PublishProperty(int propertyID)
834
+        {
835
+            var property = dBContext.Properties.Where(p => p.Id == propertyID).FirstOrDefault();
836
+            if (property != null)
837
+            {
838
+                property.Published = true;
839
+                property.DatePublished = DateTime.Now;
840
+                Update(property);
841
+            }
842
+        }
843
+
844
+        public void UnpublishProperty(int propertyID)
845
+        {
846
+            var property = dBContext.Properties.Where(p => p.Id == propertyID).FirstOrDefault();
847
+            if (property != null)
848
+            {
849
+                property.Published = false;
850
+                property.DatePublished = DateTime.MinValue;
851
+                Update(property);
852
+            }
853
+        }        
819
     }
854
     }
820
 }
855
 }

+ 3
- 0
UnivateProperties_API/Startup.cs View File

14
 using UnivateProperties_API.Helpers;
14
 using UnivateProperties_API.Helpers;
15
 using UnivateProperties_API.Model.Banks;
15
 using UnivateProperties_API.Model.Banks;
16
 using UnivateProperties_API.Model.Communication;
16
 using UnivateProperties_API.Model.Communication;
17
+using UnivateProperties_API.Model.Financial;
17
 using UnivateProperties_API.Model.Misc;
18
 using UnivateProperties_API.Model.Misc;
18
 using UnivateProperties_API.Model.ProcessFlow;
19
 using UnivateProperties_API.Model.ProcessFlow;
19
 using UnivateProperties_API.Model.Properties;
20
 using UnivateProperties_API.Model.Properties;
23
 using UnivateProperties_API.Repository;
24
 using UnivateProperties_API.Repository;
24
 using UnivateProperties_API.Repository.Banks;
25
 using UnivateProperties_API.Repository.Banks;
25
 using UnivateProperties_API.Repository.Communication;
26
 using UnivateProperties_API.Repository.Communication;
27
+using UnivateProperties_API.Repository.Financial;
26
 using UnivateProperties_API.Repository.Logging;
28
 using UnivateProperties_API.Repository.Logging;
27
 using UnivateProperties_API.Repository.Misc;
29
 using UnivateProperties_API.Repository.Misc;
28
 using UnivateProperties_API.Repository.ProccessFlow;
30
 using UnivateProperties_API.Repository.ProccessFlow;
110
             services.AddTransient<IRepository<PropertyUserField>, PropertyUserFieldRepository>();
112
             services.AddTransient<IRepository<PropertyUserField>, PropertyUserFieldRepository>();
111
             services.AddTransient<IRepository<UserDefinedField>, UserDefinedFieldRepository>();
113
             services.AddTransient<IRepository<UserDefinedField>, UserDefinedFieldRepository>();
112
             services.AddTransient<IUserDefinedGroupRepository, UserDefinedGroupRepository>();
114
             services.AddTransient<IUserDefinedGroupRepository, UserDefinedGroupRepository>();
115
+            services.AddTransient<IRepository<Payment>, PaymentRepository>();
113
 
116
 
114
             #endregion Property
117
             #endregion Property
115
             #region Region
118
             #region Region

Loading…
Cancel
Save