|
@@ -447,6 +447,7 @@ namespace UnivateProperties_API.Repository.Timeshare
|
447
|
447
|
var address = _dbContext.Addresses.Where(a => a.Id == sellItem.OwnerObject.Address.Id).FirstOrDefault();
|
448
|
448
|
var banking = _dbContext.BankAccounts.Where(b => b.Id == sellItem.OwnerObject.BankingDetails.Id).FirstOrDefault();
|
449
|
449
|
var status = _dbContext.Status.Where(s => s.Code == "A1" && s.StatusType == StatusType.Timeshare).FirstOrDefault();
|
|
450
|
+ var agent = _dbContext.Agents.Where(ag => ag.Id == sellItem.AgentId).FirstOrDefault();
|
450
|
451
|
|
451
|
452
|
#region Address
|
452
|
453
|
if (sellItem.OwnerObject.Address.PostalCode != "")
|
|
@@ -536,7 +537,7 @@ namespace UnivateProperties_API.Repository.Timeshare
|
536
|
537
|
#endregion
|
537
|
538
|
|
538
|
539
|
var week = new TimeshareWeek();
|
539
|
|
- foreach(string prop in week.GetAllProperties())
|
|
540
|
+ foreach (string prop in week.GetAllProperties())
|
540
|
541
|
{
|
541
|
542
|
if (prop != "Item" && prop != "Display")
|
542
|
543
|
week[prop] = sellItem[prop];
|
|
@@ -545,6 +546,34 @@ namespace UnivateProperties_API.Repository.Timeshare
|
545
|
546
|
week.RegionId = sellItem.Region.Id;
|
546
|
547
|
week.OwnerId = owner.Id;
|
547
|
548
|
|
|
549
|
+ TemplateRepository templateRepository = new TemplateRepository(_dbContext);
|
|
550
|
+
|
|
551
|
+ var template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-Owner");
|
|
552
|
+ if (agent != null)
|
|
553
|
+ {
|
|
554
|
+ sellItem.Agent = agent;
|
|
555
|
+ template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-Agent");
|
|
556
|
+ if (template != null)
|
|
557
|
+ {
|
|
558
|
+ templateRepository.SendEmailTemplate(template, agent, new List<BaseEntity>() { sellItem, sellItem.Owner });
|
|
559
|
+ }
|
|
560
|
+ }
|
|
561
|
+ else if (sellItem.Owner != null)
|
|
562
|
+ {
|
|
563
|
+
|
|
564
|
+ if (template != null)
|
|
565
|
+ {
|
|
566
|
+ templateRepository.SendEmailTemplate(template, sellItem.Owner, new List<BaseEntity>() { sellItem, sellItem.Owner });
|
|
567
|
+ }
|
|
568
|
+ template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-UV");
|
|
569
|
+ if (template != null)
|
|
570
|
+ {
|
|
571
|
+ templateRepository.SendEmailTemplate(template, sellItem.Owner, new List<BaseEntity>() { sellItem, sellItem.Owner });
|
|
572
|
+ }
|
|
573
|
+
|
|
574
|
+ }
|
|
575
|
+
|
|
576
|
+
|
548
|
577
|
week.StatusId = status.Id;
|
549
|
578
|
_dbContext.Add(week);
|
550
|
579
|
Save();
|