|
@@ -1,6 +1,7 @@
|
1
|
1
|
using Microsoft.EntityFrameworkCore;
|
2
|
2
|
using Newtonsoft.Json;
|
3
|
3
|
using System;
|
|
4
|
+using System.IO;
|
4
|
5
|
using System.Collections.Generic;
|
5
|
6
|
using System.Linq;
|
6
|
7
|
using UnivateProperties_API.Containers.Property;
|
|
@@ -8,6 +9,7 @@ using UnivateProperties_API.Containers.Timeshare;
|
8
|
9
|
using UnivateProperties_API.Context;
|
9
|
10
|
using UnivateProperties_API.Model.Logging;
|
10
|
11
|
using UnivateProperties_API.Model.Properties;
|
|
12
|
+using System.Drawing;
|
11
|
13
|
|
12
|
14
|
namespace UnivateProperties_API.Repository.Properties
|
13
|
15
|
{
|
|
@@ -161,11 +163,28 @@ namespace UnivateProperties_API.Repository.Properties
|
161
|
163
|
orderby p.Id descending
|
162
|
164
|
select p.Id).FirstOrDefault();
|
163
|
165
|
|
|
166
|
+ bool saveFiles = false;
|
|
167
|
+ var loc = dBContext.Location.FirstOrDefault().PropertyImageLocation;
|
|
168
|
+ if (!string.IsNullOrEmpty(loc))
|
|
169
|
+ {
|
|
170
|
+ saveFiles = true;
|
|
171
|
+ loc += string.Format("\\{0}", item.Id);
|
|
172
|
+ if (Directory.Exists(loc))
|
|
173
|
+ {
|
|
174
|
+ Directory.CreateDirectory(loc);
|
|
175
|
+ }
|
|
176
|
+ }
|
|
177
|
+
|
164
|
178
|
foreach (PropertyImage image in images)
|
165
|
179
|
{
|
166
|
180
|
lastID++;
|
167
|
181
|
image.Id = lastID;
|
168
|
182
|
image.PropertyId = item.Id;
|
|
183
|
+ if (saveFiles)
|
|
184
|
+ {
|
|
185
|
+ string path = ImageFormatter.Base64ToImage(image.Image, loc, lastID.ToString());
|
|
186
|
+ image.Image = path;
|
|
187
|
+ }
|
169
|
188
|
dBContext.PropertyImages.Add(image);
|
170
|
189
|
Save();
|
171
|
190
|
}
|
|
@@ -258,7 +277,7 @@ namespace UnivateProperties_API.Repository.Properties
|
258
|
277
|
Type = "Property"
|
259
|
278
|
};
|
260
|
279
|
|
261
|
|
- if (!string.IsNullOrEmpty(search.Keyword) && search.Keyword.ToUpper() != "ALL")
|
|
280
|
+ if (!string.IsNullOrEmpty(search.Keyword) && search.Keyword.ToUpper() != "ALL" && search.Keyword.ToUpper() != "UNDEFINED")
|
262
|
281
|
{
|
263
|
282
|
string keyword = search.Keyword.ToLower();
|
264
|
283
|
|
|
@@ -442,6 +461,11 @@ namespace UnivateProperties_API.Repository.Properties
|
442
|
461
|
select p.UsageType.ToString()).FirstOrDefault()
|
443
|
462
|
};
|
444
|
463
|
|
|
464
|
+ if (!display.DisplayImage.StartsWith("data:image"))
|
|
465
|
+ {
|
|
466
|
+ display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
|
|
467
|
+ }
|
|
468
|
+
|
445
|
469
|
if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
|
446
|
470
|
{
|
447
|
471
|
display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
|
|
@@ -470,10 +494,27 @@ namespace UnivateProperties_API.Repository.Properties
|
470
|
494
|
return GetDisplayDetails(props);
|
471
|
495
|
}
|
472
|
496
|
|
473
|
|
- public List<PropertyList> GetPropertyList(Func<Property, bool> where)
|
|
497
|
+ public List<PropertyList> GetPropertyList(string Type, int By)
|
474
|
498
|
{
|
475
|
|
- var properties = Get(where);
|
476
|
|
-
|
|
499
|
+ var individual = dBContext.Individuals.Where(x => x.UserId == By).FirstOrDefault();
|
|
500
|
+ var agent = dBContext.Agents.Where(x => x.UserId == By).FirstOrDefault();
|
|
501
|
+
|
|
502
|
+ List<Property> properties = new List<Property>();
|
|
503
|
+ if (Type.ToUpper() == "MY")
|
|
504
|
+ {
|
|
505
|
+ if (individual != null)
|
|
506
|
+ properties = Get(x => x.OwnerId == individual.Id);
|
|
507
|
+ if (agent != null)
|
|
508
|
+ properties = Get(x => x.AgentId == agent.Id);
|
|
509
|
+ }
|
|
510
|
+ else
|
|
511
|
+ {
|
|
512
|
+ if (individual != null)
|
|
513
|
+ properties = Get(x => x.OwnerId == individual.Id);
|
|
514
|
+ if (agent != null)
|
|
515
|
+ properties = Get(x => x.AgencyId == agent.AgencyId);
|
|
516
|
+ }
|
|
517
|
+
|
477
|
518
|
List<PropertyList> list = new List<PropertyList>();
|
478
|
519
|
|
479
|
520
|
foreach (Property p in properties)
|
|
@@ -498,6 +539,9 @@ namespace UnivateProperties_API.Repository.Properties
|
498
|
539
|
prop.Size = prop.Size.Substring(0, prop.Size.Length - 1) + "<sup>" + prop.Size.Last() + "</sup>";
|
499
|
540
|
}
|
500
|
541
|
|
|
542
|
+ prop.UsageType = (dBContext.PropertyTypes.Find(p.PropertyTypeId).UsageType == PropertyUsageType.Residential ? "Residential" : "Commercial");
|
|
543
|
+ prop.SaleType = p.IsSale ? "Sale" : "Rental";
|
|
544
|
+
|
501
|
545
|
list.Add(prop);
|
502
|
546
|
}
|
503
|
547
|
|
|
@@ -508,6 +552,6 @@ namespace UnivateProperties_API.Repository.Properties
|
508
|
552
|
{
|
509
|
553
|
// Not sure if properties need it
|
510
|
554
|
return 0;
|
511
|
|
- }
|
|
555
|
+ }
|
512
|
556
|
}
|
513
|
557
|
}
|