ソースを参照

Changes made to Property Addresses

master
George Williams 4年前
コミット
14c411437a

+ 0
- 77
UnivateProperties_API/Controllers/Region/CityController.cs ファイルの表示

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

+ 0
- 82
UnivateProperties_API/Controllers/Region/SuburbController.cs ファイルの表示

@@ -1,82 +0,0 @@
1
-using Microsoft.AspNetCore.Mvc;
2
-using System.Transactions;
3
-using UnivateProperties_API.Model.Region;
4
-using UnivateProperties_API.Repository.Region;
5
-
6
-namespace UnivateProperties_API.Controllers.Region
7
-{
8
-    [Route("api/[controller]")]
9
-    [ApiController]
10
-    public class SuburbController : ControllerBase
11
-    {
12
-        private readonly ISuburbRepository _Repo;
13
-
14
-        public SuburbController(ISuburbRepository repo)
15
-        {
16
-            _Repo = repo;
17
-        }
18
-
19
-        [HttpGet]
20
-        public IActionResult Get()
21
-        {
22
-            return new OkObjectResult(_Repo.GetAll());
23
-        }
24
-
25
-        [HttpGet("GetSearchList")]
26
-        public IActionResult GetSearchList()
27
-        {
28
-            return new OkObjectResult(_Repo.GetSearchList());
29
-        }
30
-
31
-        [HttpGet("GetByProperty/{id}")]
32
-        public IActionResult GetByProperty(int id)
33
-        {
34
-            return new OkObjectResult(_Repo.GetByProperty(id));
35
-        }
36
-
37
-        [HttpGet("{id}")]
38
-        public IActionResult Get(int id)
39
-        {
40
-            return new OkObjectResult(_Repo.Get(x => x.Id == id));
41
-        }
42
-
43
-        [HttpGet("{province}/{city}")]
44
-        public IActionResult Get(string Province, string City)
45
-        {
46
-            return new OkObjectResult(_Repo.GetBy(Province, City));
47
-        }
48
-
49
-        [HttpPost]
50
-        public IActionResult Post([FromBody] Suburb suburb)
51
-        {
52
-            using (var scope = new TransactionScope())
53
-            {
54
-                _Repo.Insert(suburb);
55
-                scope.Complete();
56
-                return CreatedAtAction(nameof(Get), new { id = suburb.Id }, suburb);
57
-            }
58
-        }
59
-
60
-        [HttpPut]
61
-        public IActionResult Put([FromBody] Suburb suburb)
62
-        {
63
-            if (suburb != null)
64
-            {
65
-                using (var scope = new TransactionScope())
66
-                {
67
-                    _Repo.Update(suburb);
68
-                    scope.Complete();
69
-                    return new OkResult();
70
-                }
71
-            }
72
-            return new NoContentResult();
73
-        }
74
-
75
-        [HttpDelete("{id}")]
76
-        public IActionResult Delete(int id)
77
-        {
78
-            _Repo.RemoveAtId(id);
79
-            return new OkResult();
80
-        }
81
-    }
82
-}

+ 1555
- 0
UnivateProperties_API/Migrations/20200902101725_Property-Addresses updated.Designer.cs
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 118
- 0
UnivateProperties_API/Migrations/20200902101725_Property-Addresses updated.cs ファイルの表示

@@ -0,0 +1,118 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class PropertyAddressesupdated : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.DropColumn(
10
+                name: "CityId",
11
+                table: "Properties");
12
+
13
+            migrationBuilder.DropColumn(
14
+                name: "ProvinceId",
15
+                table: "Properties");
16
+
17
+            migrationBuilder.DropColumn(
18
+                name: "SuburbId",
19
+                table: "Properties");
20
+
21
+            migrationBuilder.RenameColumn(
22
+                name: "AddressLine3",
23
+                table: "Properties",
24
+                newName: "Suburb");
25
+
26
+            migrationBuilder.RenameColumn(
27
+                name: "AddressLine2",
28
+                table: "Properties",
29
+                newName: "StreetNumber");
30
+
31
+            migrationBuilder.RenameColumn(
32
+                name: "AddressLine1",
33
+                table: "Properties",
34
+                newName: "StreetName");
35
+
36
+            migrationBuilder.AddColumn<string>(
37
+                name: "AddressOther",
38
+                table: "Properties",
39
+                nullable: true);
40
+
41
+            migrationBuilder.AddColumn<string>(
42
+                name: "City",
43
+                table: "Properties",
44
+                nullable: true);
45
+
46
+            migrationBuilder.AddColumn<string>(
47
+                name: "Country",
48
+                table: "Properties",
49
+                nullable: true);
50
+
51
+            migrationBuilder.AddColumn<string>(
52
+                name: "PostalCode",
53
+                table: "Properties",
54
+                nullable: true);
55
+
56
+            migrationBuilder.AddColumn<string>(
57
+                name: "Province",
58
+                table: "Properties",
59
+                nullable: true);
60
+        }
61
+
62
+        protected override void Down(MigrationBuilder migrationBuilder)
63
+        {
64
+            migrationBuilder.DropColumn(
65
+                name: "AddressOther",
66
+                table: "Properties");
67
+
68
+            migrationBuilder.DropColumn(
69
+                name: "City",
70
+                table: "Properties");
71
+
72
+            migrationBuilder.DropColumn(
73
+                name: "Country",
74
+                table: "Properties");
75
+
76
+            migrationBuilder.DropColumn(
77
+                name: "PostalCode",
78
+                table: "Properties");
79
+
80
+            migrationBuilder.DropColumn(
81
+                name: "Province",
82
+                table: "Properties");
83
+
84
+            migrationBuilder.RenameColumn(
85
+                name: "Suburb",
86
+                table: "Properties",
87
+                newName: "AddressLine3");
88
+
89
+            migrationBuilder.RenameColumn(
90
+                name: "StreetNumber",
91
+                table: "Properties",
92
+                newName: "AddressLine2");
93
+
94
+            migrationBuilder.RenameColumn(
95
+                name: "StreetName",
96
+                table: "Properties",
97
+                newName: "AddressLine1");
98
+
99
+            migrationBuilder.AddColumn<int>(
100
+                name: "CityId",
101
+                table: "Properties",
102
+                nullable: false,
103
+                defaultValue: 0);
104
+
105
+            migrationBuilder.AddColumn<int>(
106
+                name: "ProvinceId",
107
+                table: "Properties",
108
+                nullable: false,
109
+                defaultValue: 0);
110
+
111
+            migrationBuilder.AddColumn<int>(
112
+                name: "SuburbId",
113
+                table: "Properties",
114
+                nullable: false,
115
+                defaultValue: 0);
116
+        }
117
+    }
118
+}

+ 1557
- 0
UnivateProperties_API/Migrations/20200903063044_property address url.Designer.cs
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 22
- 0
UnivateProperties_API/Migrations/20200903063044_property address url.cs ファイルの表示

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

+ 1559
- 0
UnivateProperties_API/Migrations/20200903075657_property show address.Designer.cs
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 23
- 0
UnivateProperties_API/Migrations/20200903075657_property show address.cs ファイルの表示

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

+ 15
- 7
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs ファイルの表示

@@ -610,17 +610,17 @@ namespace UnivateProperties_API.Migrations
610 610
                         .ValueGeneratedOnAdd()
611 611
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
612 612
 
613
-                    b.Property<string>("AddressLine1");
613
+                    b.Property<string>("AddressOther");
614 614
 
615
-                    b.Property<string>("AddressLine2");
616
-
617
-                    b.Property<string>("AddressLine3");
615
+                    b.Property<string>("AddressURL");
618 616
 
619 617
                     b.Property<int?>("AgencyId");
620 618
 
621 619
                     b.Property<int?>("AgentId");
622 620
 
623
-                    b.Property<int>("CityId");
621
+                    b.Property<string>("City");
622
+
623
+                    b.Property<string>("Country");
624 624
 
625 625
                     b.Property<DateTime>("Created");
626 626
 
@@ -642,6 +642,8 @@ namespace UnivateProperties_API.Migrations
642 642
 
643 643
                     b.Property<int?>("OwnerId");
644 644
 
645
+                    b.Property<string>("PostalCode");
646
+
645 647
                     b.Property<decimal>("Price");
646 648
 
647 649
                     b.Property<string>("PricePer");
@@ -652,17 +654,23 @@ namespace UnivateProperties_API.Migrations
652 654
 
653 655
                     b.Property<int>("PropertyTypeId");
654 656
 
655
-                    b.Property<int>("ProvinceId");
657
+                    b.Property<string>("Province");
656 658
 
657 659
                     b.Property<bool>("Published");
658 660
 
659 661
                     b.Property<string>("ShortDescription");
660 662
 
663
+                    b.Property<bool>("ShowAddress");
664
+
661 665
                     b.Property<DateTime>("StatusDate");
662 666
 
663 667
                     b.Property<int?>("StatusId");
664 668
 
665
-                    b.Property<int>("SuburbId");
669
+                    b.Property<string>("StreetName");
670
+
671
+                    b.Property<string>("StreetNumber");
672
+
673
+                    b.Property<string>("Suburb");
666 674
 
667 675
                     b.Property<string>("Unit");
668 676
 

+ 12
- 14
UnivateProperties_API/Model/Properties/Property.cs ファイルの表示

@@ -23,13 +23,17 @@ namespace UnivateProperties_API.Model.Properties
23 23
         public bool IsSale { get; set; }
24 24
         public string Description { get; set; }
25 25
         public string ShortDescription { get; set; }
26
-        public string AddressLine1 { get; set; }
27
-        public string AddressLine2 { get; set; }
28
-        public string AddressLine3 { get; set; }
29
-        public string PropertCoords { get; set; }
30
-        public int SuburbId { get; set; }
31
-        public int CityId { get; set; }
32
-        public int ProvinceId { get; set; }
26
+        public bool ShowAddress { get; set; }
27
+        public string AddressOther { get; set; } 
28
+        public string StreetNumber { get; set; }
29
+        public string StreetName { get; set; }
30
+        public string Suburb { get; set; }
31
+        public string City { get; set; }
32
+        public string Province { get; set; }
33
+        public string Country { get; set; }
34
+        public string PostalCode { get; set; }
35
+        public string PropertCoords { get; set; }  
36
+        public string AddressURL { get; set; }
33 37
         public bool Published { get; set; }
34 38
         public DateTime DatePublished { get; set; }
35 39
         public string VirtualTour { get; set; }
@@ -58,13 +62,7 @@ namespace UnivateProperties_API.Model.Properties
58 62
         public int? AgencyId { get; set; }
59 63
         public DateTime DateAvailable { get; set; }
60 64
         public DateTime StatusDate { get; set; }        
61
-        public virtual PropertyType PropertyType { get; set; }    
62
-        [NotMapped]
63
-        public Province Province { get; set; }
64
-        [NotMapped]
65
-        public City City { get; set; }
66
-        [NotMapped]
67
-        public Suburb Suburb { get; set; }
65
+        public virtual PropertyType PropertyType { get; set; }            
68 66
         [NotMapped]
69 67
         public Status Status { get; set; }        
70 68
         public virtual Individual Owner { get; set; }        

+ 17
- 15
UnivateProperties_API/Repository/Misc/CarouselRepository.cs ファイルの表示

@@ -160,14 +160,15 @@ namespace UnivateProperties_API.Repository.Misc
160 160
                 {
161 161
                     var property = dBContext.Properties.Where(p => p.Id == item.PropertyId).FirstOrDefault();
162 162
 
163
-                    if (property != null)
164
-                    {                        
165
-                        property.Province = dBContext.Provinces.Where(p => p.Id == property.ProvinceId).FirstOrDefault();
166
-                        property.City = dBContext.Cities.Where(c => c.Id == property.CityId).FirstOrDefault();
167
-                        property.Suburb = dBContext.Suburbs.Where(s => s.Id == property.SuburbId).FirstOrDefault();
168
-                    }
169
-
170
-                    carItem.Address = string.Format("{0}, {1} <br/>{2}", property.Suburb.Description, property.City.Description, property.AddressLine3);
163
+                    //Carousel is no longer used. This code was changed on the model
164
+                    //if (property != null)
165
+                    //{                        
166
+                    //    property.Province = dBContext.Provinces.Where(p => p.Id == property.ProvinceId).FirstOrDefault();
167
+                    //    property.City = dBContext.Cities.Where(c => c.Id == property.CityId).FirstOrDefault();
168
+                    //    property.Suburb = dBContext.Suburbs.Where(s => s.Id == property.SuburbId).FirstOrDefault();
169
+                    //}
170
+
171
+                    //carItem.Address = string.Format("{0}, {1} <br/>{2}", property.Suburb.Description, property.City.Description, property.AddressOther);
171 172
                     carItem.IsProperty = true;
172 173
                 }
173 174
                 if (item.TimeshareId > 0)
@@ -202,13 +203,14 @@ namespace UnivateProperties_API.Repository.Misc
202 203
                 if (item.PropertyId > 0)
203 204
                 {
204 205
                     var property = dBContext.Properties.Where(p => p.Id == item.PropertyId).FirstOrDefault();
205
-                    if (property != null)
206
-                    {
207
-                        property.Province = dBContext.Provinces.Where(p => p.Id == property.ProvinceId).FirstOrDefault();
208
-                        property.City = dBContext.Cities.Where(c => c.Id == property.CityId).FirstOrDefault();
209
-                        property.Suburb = dBContext.Suburbs.Where(s => s.Id == property.SuburbId).FirstOrDefault();
210
-                    }
211
-                    item.Address = string.Format("{0}, {1} <br/>{2}", property.Suburb.Description, property.City.Description, property.AddressLine3);
206
+                    //
207
+                    //if (property != null)
208
+                    //{
209
+                    //    property.Province = dBContext.Provinces.Where(p => p.Id == property.ProvinceId).FirstOrDefault();
210
+                    //    property.City = dBContext.Cities.Where(c => c.Id == property.CityId).FirstOrDefault();
211
+                    //    property.Suburb = dBContext.Suburbs.Where(s => s.Id == property.SuburbId).FirstOrDefault();
212
+                    //}
213
+                    //item.Address = string.Format("{0}, {1} <br/>{2}", property.Suburb.Description, property.City.Description, property.AddressOther);
212 214
                     item.IsProperty = true;
213 215
                 }
214 216
                 if (item.TimeshareId > 0)

+ 33
- 35
UnivateProperties_API/Repository/Properties/PropertyRepository.cs ファイルの表示

@@ -53,7 +53,19 @@ namespace UnivateProperties_API.Repository.Properties
53 53
             {
54 54
                 return GetDetail(property, detailed);
55 55
             }
56
-            return null;
56
+            else
57
+            {
58
+                var prop = new PropertyContainer
59
+                {
60
+                    PropertyImages = new List<PropertyImage>(),
61
+                    PropertyUserFields = new List<PropertyUserField>(),
62
+                    NewImages = new List<NewImage>(),
63
+                    PropertyOverviewFields = new List<PropertyFieldGroup>(),
64
+                    PropertyFields = new List<PropertyFieldGroup>()
65
+                };
66
+
67
+                return prop;
68
+            }
57 69
         }
58 70
 
59 71
         public List<Property> GetDetailedAll()
@@ -65,10 +77,7 @@ namespace UnivateProperties_API.Repository.Properties
65 77
         private PropertyContainer GetDetail(Property property, bool detailed)
66 78
         {            
67 79
             int propID = property.Id;
68
-            var propertyType = dBContext.PropertyTypes.Find(property.PropertyTypeId);
69
-            property.Province = dBContext.Provinces.Find(property.ProvinceId);
70
-            property.City = dBContext.Cities.Find(property.CityId);
71
-            property.Suburb = dBContext.Suburbs.Find(property.SuburbId);
80
+            var propertyType = dBContext.PropertyTypes.Find(property.PropertyTypeId);           
72 81
             property.DisplayData = new List<PropertyDetailGroup>();            
73 82
 
74 83
             if (detailed)
@@ -343,15 +352,12 @@ namespace UnivateProperties_API.Repository.Properties
343 352
             {
344 353
                 string keyword = search.Keyword.ToLower();
345 354
 
346
-                List<Property> props = (from p in dBContext.Properties
347
-                                        join pr in dBContext.Provinces on p.ProvinceId equals pr.Id
348
-                                        join c in dBContext.Cities on p.CityId equals c.Id
349
-                                        join s in dBContext.Suburbs on p.SuburbId equals s.Id
355
+                List<Property> props = (from p in dBContext.Properties                                       
350 356
                                         join pt in dBContext.PropertyTypes on p.PropertyTypeId equals pt.Id
351 357
                                         where EF.Functions.Like(p.PropertyName.ToLower(), $"%{keyword}%")
352
-                                        || EF.Functions.Like(pr.Description.ToLower(), $"%{keyword}%")
353
-                                        || EF.Functions.Like(c.Description.ToLower(), $"%{keyword}%")
354
-                                        || EF.Functions.Like(s.Description.ToLower(), $"%{keyword}%")
358
+                                        || EF.Functions.Like(p.Province.ToLower(), $"%{keyword}%")
359
+                                        || EF.Functions.Like(p.City.ToLower(), $"%{keyword}%")
360
+                                        || EF.Functions.Like(p.Suburb.ToLower(), $"%{keyword}%")
355 361
                                         || EF.Functions.Like(pt.Description.ToLower(), $"%{keyword}%")
356 362
                                         select p).ToList();
357 363
                 obj.Property = "Keyword";
@@ -410,9 +416,8 @@ namespace UnivateProperties_API.Repository.Properties
410 416
 
411 417
                 if (!string.IsNullOrEmpty(search.Province) && search.Province != "undefined" && search.Province.ToUpper() != "ALL")
412 418
                 {
413
-                    props = (from p in props
414
-                             join pp in dBContext.Provinces on p.ProvinceId equals pp.Id
415
-                             where pp.Description.ToUpper() == search.Province.ToUpper()
419
+                    props = (from p in props                            
420
+                             where p.Province.ToUpper() == search.Province.ToUpper()
416 421
                              select p).ToList();
417 422
 
418 423
                     obj.Property = "Province";
@@ -422,9 +427,8 @@ namespace UnivateProperties_API.Repository.Properties
422 427
 
423 428
                 if (!string.IsNullOrEmpty(search.City) && search.City != "undefined" && search.City.ToUpper() != "ALL")
424 429
                 {
425
-                    props = (from p in props
426
-                             join c in dBContext.Cities on p.CityId equals c.Id
427
-                             where c.Description.ToUpper() == search.City.ToUpper()
430
+                    props = (from p in props                             
431
+                             where p.City.ToUpper() == search.City.ToUpper()
428 432
                              select p).ToList();
429 433
 
430 434
                     obj.Property = "City";
@@ -434,9 +438,8 @@ namespace UnivateProperties_API.Repository.Properties
434 438
 
435 439
                 if (!string.IsNullOrEmpty(search.Suburb) && search.Suburb != "undefined" && search.Suburb.ToUpper() != "ALL")
436 440
                 {
437
-                    props = (from p in props
438
-                             join s in dBContext.Suburbs on p.SuburbId equals s.Id
439
-                             where s.Description.ToUpper() == search.Suburb.ToUpper()
441
+                    props = (from p in props                             
442
+                             where p.Suburb.ToUpper() == search.Suburb.ToUpper()
440 443
                              select p).ToList();
441 444
 
442 445
                     obj.Property = "Suburb";
@@ -501,9 +504,9 @@ namespace UnivateProperties_API.Repository.Properties
501 504
             var properties = new List<PropertyDisplay>();
502 505
             props = props.Where(p => p.Published).ToList();
503 506
             foreach (var item in props)
504
-            {                
507
+            {
505 508
                 PropertyDisplay display = new PropertyDisplay
506
-                {          
509
+                {
507 510
                     DateAvailable = item.DateAvailable,
508 511
                     Available = item.DateAvailable.Date > DateTime.Now.Date ? string.Format("Available form: {0: dd MMM yyyy}", item.DateAvailable) : "Available Now",
509 512
                     Id = item.Id,
@@ -534,15 +537,9 @@ namespace UnivateProperties_API.Repository.Properties
534 537
                                where u.PropertyId == item.Id
535 538
                                && f.FieldName == "Garages"
536 539
                                select u.Value).FirstOrDefault(),
537
-                    Province = (from p in dBContext.Provinces
538
-                                where p.Id == item.ProvinceId
539
-                                select p.Description).FirstOrDefault(),
540
-                    City = (from c in dBContext.Cities
541
-                            where c.Id == item.CityId
542
-                            select c.Description).FirstOrDefault(),
543
-                    Suburb = (from s in dBContext.Suburbs
544
-                              where s.Id == item.SuburbId
545
-                              select s.Description).FirstOrDefault(),
540
+                    Province = item.Province,
541
+                    City = item.City,
542
+                    Suburb = item.Suburb,
546 543
                     Price = item.Price,
547 544
                     DateCreated = item.Created,
548 545
                     PropertyUsageType = (from p in dBContext.PropertyTypes
@@ -614,7 +611,7 @@ namespace UnivateProperties_API.Repository.Properties
614 611
                     properties = dBContext.Properties.Where(p => p.OwnerId == individual.Id).ToList();
615 612
                 }
616 613
                 if (user.Role.ToUpper() == "SUPER ADMIN")
617
-                    properties = dBContext.Properties.Include("City").Include("Suburb").ToList();
614
+                    properties = dBContext.Properties.ToList();
618 615
             }
619 616
 
620 617
             return SetPropertyList(properties);
@@ -638,7 +635,7 @@ namespace UnivateProperties_API.Repository.Properties
638 635
                     Price = p.Price,
639 636
                     Publish = p.Published ? "Yes" : "No",
640 637
                     Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description,
641
-                    CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb?.Description, p.City?.Description, p.AddressLine3),
638
+                    CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb, p.City, p.AddressOther),
642 639
                     DateAvailable = p.IsSale ? DateTime.MinValue : p.DateAvailable,
643 640
                     IsPublished = p.Published
644 641
                 };
@@ -726,7 +723,8 @@ namespace UnivateProperties_API.Repository.Properties
726 723
             if (status != null)
727 724
                 property.StatusId = status.Id;
728 725
 
729
-            property.Video = property.Video.Replace("https://www.youtube.com/watch?v=", "");
726
+            if (!string.IsNullOrEmpty(property.Video))
727
+                property.Video = property.Video.Replace("https://www.youtube.com/watch?v=", "");
730 728
 
731 729
             if (images != null)
732 730
             {

+ 0
- 128
UnivateProperties_API/Repository/Region/CityRepository.cs ファイルの表示

@@ -1,128 +0,0 @@
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.Region;
7
-
8
-namespace UnivateProperties_API.Repository.Region
9
-{
10
-    public class CityRepository : ICityRepository
11
-    {
12
-        private readonly DataContext dBContext;
13
-
14
-        public CityRepository(DataContext _dBContext)
15
-        {
16
-            dBContext = _dBContext;
17
-        }
18
-
19
-        public List<City> Get(Func<City, bool> where)
20
-        {
21
-            return dBContext.Cities.Where(where).ToList();
22
-        }        
23
-
24
-        public List<City> GetAll()
25
-        {
26
-            return dBContext.Cities.ToList();
27
-        }
28
-
29
-        public List<City> GetBy(string province)
30
-        {
31
-            var provObj = dBContext.Provinces.Where(p => p.Description == province).First();
32
-            if (provObj != null)
33
-                return dBContext.Cities.Where(c => c.ProvinceId == provObj.Id).OrderBy(c => c.Description).ToList();
34
-            else
35
-                return null;
36
-        }
37
-
38
-        public City GetDetailed(Func<City, bool> first)
39
-        {
40
-            throw new NotImplementedException();
41
-        }
42
-
43
-        public List<City> GetDetailedAll()
44
-        {
45
-            throw new NotImplementedException();
46
-        }
47
-
48
-        public void Insert(City item)
49
-        {
50
-            item.Id = NewId();
51
-            dBContext.Add(item);
52
-            Save();
53
-        }
54
-
55
-        public void Insert(IEnumerable<City> items)
56
-        {
57
-            int id = NewId();
58
-            foreach (var item in items)
59
-            {
60
-                item.Id = id;
61
-                dBContext.Add(item);
62
-                id += 1;
63
-            }
64
-            Save();
65
-        }
66
-
67
-        public void Remove(City item)
68
-        {
69
-            dBContext.Cities.Remove(item);
70
-            Save();
71
-        }
72
-
73
-        public void Remove(IEnumerable<City> items)
74
-        {
75
-            foreach (var item in items)
76
-            {
77
-                dBContext.Cities.Remove(item);
78
-            }
79
-            Save();
80
-        }
81
-
82
-        public void RemoveAtId(int item)
83
-        {
84
-            var city = Get(x => x.Id == item).FirstOrDefault();
85
-            if (city != null)
86
-            {
87
-                dBContext.Cities.Remove(city);
88
-                Save();
89
-            }
90
-        }
91
-
92
-        public void Save()
93
-        {
94
-            dBContext.SaveChanges();
95
-        }
96
-
97
-        public void Update(City item)
98
-        {
99
-            dBContext.Entry(item).State = EntityState.Modified;
100
-            Save();
101
-        }
102
-
103
-        public int NewId()
104
-        {
105
-            int id = 0;
106
-            if (dBContext.Cities.Count() > 0)
107
-            {
108
-                id = dBContext.Cities.Max(x => x.Id);
109
-            }
110
-            id += 1;
111
-            return id;
112
-        }
113
-
114
-        public List<City> GetByProperty(int propertyId)
115
-        {
116
-            var prop = dBContext.Properties.Where(p => p.Id == propertyId).FirstOrDefault();
117
-            if (prop != null)
118
-            {
119
-                var Cities = dBContext.Cities.Where(s => s.ProvinceId == prop.ProvinceId).ToList();
120
-                return Cities;
121
-            }
122
-            else
123
-            {
124
-                return null;
125
-            }
126
-        }
127
-    }
128
-}

+ 0
- 11
UnivateProperties_API/Repository/Region/ICityRepository.cs ファイルの表示

@@ -1,11 +0,0 @@
1
-using System.Collections.Generic;
2
-using UnivateProperties_API.Model.Region;
3
-
4
-namespace UnivateProperties_API.Repository.Region
5
-{
6
-    public interface ICityRepository : IRepository<City>
7
-    {
8
-        List<City> GetBy(string province);
9
-        List<City> GetByProperty(int propertyId);
10
-    }
11
-}

+ 0
- 13
UnivateProperties_API/Repository/Region/ISuburbRepository.cs ファイルの表示

@@ -1,13 +0,0 @@
1
-using System.Collections.Generic;
2
-using UnivateProperties_API.Containers.Regions;
3
-using UnivateProperties_API.Model.Region;
4
-
5
-namespace UnivateProperties_API.Repository.Region
6
-{
7
-    public interface ISuburbRepository : IRepository<Suburb>
8
-    {
9
-        List<Suburb> GetBy(string province, string city);
10
-        List<SuburbSearch> GetSearchList();
11
-        List<Suburb> GetByProperty(int propertyId);
12
-    }
13
-}

+ 0
- 161
UnivateProperties_API/Repository/Region/SuburbRepository.cs ファイルの表示

@@ -1,161 +0,0 @@
1
-using Microsoft.EntityFrameworkCore;
2
-using System;
3
-using System.Collections.Generic;
4
-using System.Linq;
5
-using UnivateProperties_API.Containers.Regions;
6
-using UnivateProperties_API.Context;
7
-using UnivateProperties_API.Model.Region;
8
-
9
-namespace UnivateProperties_API.Repository.Region
10
-{
11
-    public class SuburbRepository : ISuburbRepository
12
-    {
13
-        private readonly DataContext dBContext;
14
-
15
-        public SuburbRepository(DataContext _dBContext)
16
-        {
17
-            dBContext = _dBContext;
18
-        }
19
-
20
-        public List<Suburb> Get(Func<Suburb, bool> where)
21
-        {
22
-            return dBContext.Suburbs.Where(where).ToList();
23
-        }
24
-
25
-        public List<Suburb> GetAll()
26
-        {
27
-            return dBContext.Suburbs.ToList();
28
-        }
29
-
30
-        public List<Suburb> GetBy(string province, string city)
31
-        {
32
-            var provObj = dBContext.Provinces.Where(p => p.Description == province).FirstOrDefault();
33
-            var cityObj = dBContext.Cities.Where(c => c.ProvinceId == provObj.Id && c.Description == city).FirstOrDefault();
34
-            if (cityObj != null)
35
-                return dBContext.Suburbs.Where(s => s.CityId == cityObj.Id).OrderBy(s => s.Description).ToList();
36
-            else
37
-                return null;
38
-        }
39
-
40
-        public Suburb GetDetailed(Func<Suburb, bool> first)
41
-        {
42
-            throw new NotImplementedException();
43
-        }
44
-
45
-        public List<Suburb> GetDetailedAll()
46
-        {
47
-            throw new NotImplementedException();
48
-        }
49
-
50
-        public void Insert(Suburb item)
51
-        {
52
-            item.Id = NewId();
53
-            dBContext.Add(item);
54
-            Save();
55
-        }
56
-
57
-        public void Insert(IEnumerable<Suburb> items)
58
-        {
59
-            int id = NewId();
60
-            foreach (var item in items)
61
-            {
62
-                item.Id = id;
63
-                dBContext.Add(item);
64
-                id += 1;
65
-            }
66
-            Save();
67
-        }
68
-
69
-        public void Remove(Suburb item)
70
-        {
71
-            dBContext.Suburbs.Remove(item);
72
-            Save();
73
-        }
74
-
75
-        public void Remove(IEnumerable<Suburb> items)
76
-        {
77
-            foreach (var item in items)
78
-            {
79
-                dBContext.Suburbs.Remove(item);
80
-            }
81
-            Save();
82
-        }
83
-
84
-        public void RemoveAtId(int item)
85
-        {
86
-            var suburb = Get(x => x.Id == item).FirstOrDefault();
87
-            if (suburb != null)
88
-            {
89
-                dBContext.Suburbs.Remove(suburb);
90
-                Save();
91
-            }
92
-        }
93
-
94
-        public void Save()
95
-        {
96
-            dBContext.SaveChanges();
97
-        }
98
-
99
-        public void Update(Suburb item)
100
-        {
101
-            dBContext.Entry(item).State = EntityState.Modified;
102
-            Save();
103
-        }
104
-
105
-        public int NewId()
106
-        {
107
-            int id = 0;
108
-            if (dBContext.Suburbs.Count() > 0)
109
-            {
110
-                id = dBContext.Suburbs.Max(x => x.Id);
111
-            }
112
-            id += 1;
113
-            return id;
114
-        }
115
-
116
-        public List<SuburbSearch> GetSearchList()
117
-        {
118
-            var suburbs = dBContext.Suburbs.Include("City").Include("City.Province").ToList();
119
-            List<SuburbSearch> searchList = new List<SuburbSearch>();
120
-            
121
-            foreach (var sub in suburbs)
122
-            {
123
-                searchList.Add(new SuburbSearch()
124
-                {                       
125
-                    Province = sub.City.Province.Description,
126
-                    City = sub.City.Description,
127
-                    Suburb = sub.Description,
128
-                    Display = string.Format("{0} - {1}", sub.Description, sub.City.Description)
129
-                });
130
-            }
131
-
132
-            var cities = dBContext.Cities.Include("Province").ToList();
133
-            foreach(var city in cities)
134
-            {
135
-                searchList.Add(new SuburbSearch()
136
-                {                    
137
-                    Province = city.Province.Description,
138
-                    City = city.Description,
139
-                    Suburb = "",
140
-                    Display = string.Format("{0}", city.Description)
141
-                });
142
-            }
143
-
144
-            return searchList.OrderBy(s => s.City).ThenBy(s => s.Suburb).ToList();
145
-        }
146
-
147
-        public List<Suburb> GetByProperty(int propertyId)
148
-        {
149
-            var prop = dBContext.Properties.Where(p => p.Id == propertyId).FirstOrDefault();
150
-            if (prop != null)
151
-            {
152
-                var Suburbs = dBContext.Suburbs.Where(s => s.CityId == prop.CityId).ToList();
153
-                return Suburbs;
154
-            }
155
-            else
156
-            {
157
-                return null;
158
-            }
159
-        }
160
-    }
161
-}

+ 1
- 3
UnivateProperties_API/Startup.cs ファイルの表示

@@ -126,9 +126,7 @@ namespace UnivateProperties_API
126 126
             services.AddTransient<IRepository<Payment>, PaymentRepository>();            
127 127
             #endregion Property
128 128
             #region Region
129
-            services.AddTransient<IRepository<Province>, ProvinceRepository>();
130
-            services.AddTransient<ICityRepository, CityRepository>();
131
-            services.AddTransient<ISuburbRepository, SuburbRepository>();
129
+            services.AddTransient<IRepository<Province>, ProvinceRepository>();            
132 130
             #endregion Region
133 131
             #region Timeshare
134 132
             services.AddTransient<IRepository<Status>, StatusRepository>();

読み込み中…
キャンセル
保存